HostGator.com » Support Portal

.htaccess guidance

.htaccess is a special Apache file that tells your website how to function.

You can edit the existing .htaccess file on your site, or you can create a new text file in any directory and name it .htaccess

How can I secure my .htaccess file?

The file is already protected; it will be forbidden to browsers. To be very sure, double check that the file is named ".htaccess" and not "htaccess" nor "htaccess.txt". (It must start with a dot.)

Can I delete my .htaccess file permanently?

You can delete the .htaccess file, but it will reappear immediately as a blank file.

HostGator has default directives which will always be in place, unless you create your own directives to overrule ours.

Example

HostGator uses this code as a default, even if you erase and remove the .htaccess file.

DirectoryIndex index.html index.shtml index.php default.html home.html

You can override those defaults by creating your own rules.

DirectoryIndex home.html page1.php index.txt

Online Guides

If you do not code this file correctly, it can cause website errors.

Guides to dot-htaccess coding:
javascriptkit.com
apache.org
modrewrite.com
Great resource for mod rewrite lessons.
Great resource for mod rewrite examples.


I am going to give you some common dot-htaccess codes our customers love. Simply follow the Related Article link, "Apache mod_rewrite and examples".

Please remember we do not offer support to code this, nor do we promise to make your code work.


Article Comments

Eric
Doesn't every website server already come with a htaccess file? I can't seem to find mine. Do I have to create one myself?

HostGator
It is not included among your files by default. You need to create it.

Eric
Ok, for some reason, the file wasn't showing up in my Cpanel but did appear by accessing the files by my FTP. Don't know why that was but thought I should just let others know if they don't find it either. Thanks

HostGator
When you enter File manager, you must choose the check box for "Show hidden files (dot files)".

Rick
If you've ever selected "Don't show me this again" when entering cPanel, you won't be able to select "Show hidden files" as suggested above.

I just learned the following solution to this from HostGator's tech support. It works!

Scroll down on cPanel home page -->"reset all interface settings" and then go back to File Manager and it will prompt you again.

Do I need to delete the original ht access file so that the site takes its instructions from the new htaccess file that you have created?

I cannot get the permalinks to work properly, the correct code is in the htaccess. I've tried lots of things but with /%postname%/ in custom field. it shows the page title at the end of the url as it should but the page gives a 404 error. any ideas?

HostGator
Any .htaccess file stored up one level will append to the beginning of your .htaccess file. The same rule applies to that .htaccess file, and so on.

Just make sure you don't have conflicting code in the other .htaccess files.

tamas
Hello! Is modrewrite and .htaccess allowed for subdirectories?

Own htaccess for subdirectories I think ...

HostGator
Yes, you can create a unique .htaccess file for any folder.

HostGator
Thank you for your comments. Just a quick reminder that the comments on this page are not monitored by technical support staff, and that for support issues, it is best to contact us by live chat, phone or email so we can assist you right away.

Although comments are not monitored by technical support staff, they are moderated and read by technical writers. Comments will need to be approved by a moderator before appearing.

Our technical writers do read the comments periodically for the purposes of updating the articles, and do appreciate your feedback, suggestions and corrections to the articles themselves, as well as any suggestions or tips for readers of this article. However, support questions posted here are not guaranteed to be replied to in a timely manner or at all. For support issues, it is best to contact our support staff instead by live chat, email or phone.



Your comments help us keep the knowledge base updated. This is not a medium for support. If you have questions or need help, please contact us via email, phone or live chat for fast assistance.

Post Comment