How to set custom .htaccess rules?

How to set custom .htaccess rules?

.htaccess rules are a powerful way to affect how a website behaves and can be used to set pretty URLs, define error pages, restrict access and more. There are plenty of guides available to teach you everything that can be done with .htaccess.

This article explains where to set your own .htaccess rules.

Create the .htaccess file in your htdocs directory

Every domain name on your account has a htdocs directory. Your main domain is attached to the folder htdocs/, addon domains and subdomains to folders like example.com/htdocs/. In these folders, you can create a new file with the name .htaccess. In this file, you can put your .htaccess rules.

Note that the file name starts with a dot and doesn't have a "file extension". Windows notoriously has some problems with file names like that (MacOS and Linux less so) so you may want to create it through the File Manager in your control panel instead.

Most scripts already include a .htaccess file. In that case, you can edit the file which is already in the htdocs folder rather than create a new one.

Don't edit the main .htaccess file

The root folder of your account also contains a .htaccess file. You should not (and generally cannot) edit that file.

The rules inside the main .htaccess file do not have negative effects for your website and do not affect how your website works in any way. All rules inside can be overridden using the .htaccess files in the htdocs folders of specific websites.

If you do manage to remove the file, don't worry about it. Removing the file only removes the default error pages and will not affect a working website.

Still have questions? Check our forum!