Free and Unlimited Web Hosting

How to set custom .htaccess rules?

How to set custom .htaccess rules?

.htaccess rules are a powerful way to control how your website behaves. It 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 can’t explain everything you can do with .htaccess rules, but it does explain how you can add them.

Create the .htaccess file in your htdocs directory

Every domain name on your account has a htdocs directory. Your first domain is attached to the folder htdocs/ and addon domains and subdomains are linked 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 it’s easiest to create this file through our file manager. Since the file name starts with a dot and doesn’t have a name before the “extension”, computers may handle the file weridly. Windows notoriously has some problems with file names like that (MacOS and Linux less so).

Most scripts already include a .htaccess file. In that case, you can edit the file which is already in your website folder instead of creating 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 set some defaults for directory indexing and error pages. They don’t really change how your website behaves. And if you don’t like their behaviour, you can override all rules in the file using your own .htaccess file in the htdocs folder of your website.

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 break your website.

Still have questions? Check our forum!

Forget the stereotypes of free hosting!