.htaccess overview

 

Overview

This guide provides basic information about an .htaccess file and how to use one on your site.

Background

An .htaccess file controls how Apache interacts with your site. When an .htaccess file is placed in your domain’s directory, the .htaccess file is detected and executed by the Apache web server. An .htaccess file is commonly used for the following:

Creating an .htaccess file on your DreamHost web server

You can create an .htaccess directly on your web server using an FTP client or SSH. See the following articles to learn more about how to use either option to create the file:

If you're using an FTP client, make sure it has been configured to show hidden files. This is necessary since the .htaccess file begins with a period.

When you create the .htaccess file, do not add a file extension. It should only be titled .htaccess without an extension.

Troubleshooting

Using an .htaccess file on your website is unlikely to cause any problems. However, it is possible for errors to occur if the rules entered into the file are incorrect, which may cause your site to suddenly display a 500 error. If something like this occurs, you can comment out the rules/lines you have just added by placing a # in front of each line. Repeat this until you find the line causing the error.

FAQs

What permissions should the file have?

Setting 644 permissions is usually fine for an .htaccess file. When you create the file on the server, it should already have these permissions set, so there is most likely nothing to change.

Where do I put the .htaccess file?

Generally, you put the .htaccess file in your website's main directory. However, the location ultimately depends on what you're attempting to do with it.

The .htaccess file can control behavior for every directory under the folder it resides in. For this reason, it can also be in your user's home directory. Again, it depends on what you're using the .htaccess file for.

Do I need to reload my server or website after creating my .htaccess file?

Your .htaccess file (and any changes that you make to it) should be reflected on the live site immediately. You do not need to reload your site's Apache service, although you may need to flush any external caching services, such as Cloudflare.

Can I use an .htaccess file with my DreamPress site?

It is not possible to use an .htaccess file on a DreamPress site since it uses Nginx, which instead automatically handles these operations at the server level.

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?