How can I redirect and rewrite my URLs with an .htaccess file?

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. View the following articles for instructions on how to use either option to create the file:

Creating and editing a file via FTP (easier for beginners)
Creating and editing a file via SSH (for advanced users)
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.
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 the .htaccess file.

What to change in the examples below?

The examples below can be entered into your .htaccess file exactly as shown. Just make sure to adjust the actual path to the file so the .htaccess file knows where it’s located. Also, if you see the domain ‘’, change this to your own domain name.

Redirecting a URL

Using Redirect in an .htaccess file enables you to redirect users from an old page to a new page without having to keep the old page. For example, if you use index.html as your index file and then later rename index.html to home.html, you could set up a redirect to send users from index.html to home.html. For example:

Redirect to a local site file

Redirect /path/to/old/file/old.html /path/to/new/file/new.html
Redirect to an external site file
Redirect /path/to/old/file/old.html

The first path
The first path to the old file must be a local Linux path, NOT the full path. So, if the .htaccess file is in the directory /, you would not include /home/exampleuser/ in the local Linux path. The first / represents the directory. If the old file was in that directory, you would follow the / with the old file name.

The second path
The second path to the new file can be a local Linux path, but can also be a full URL to link to a page on a different server or the same server.