This document will explain how to create a .htaccess file to redirect your site or site content. This will not redirect any emails for your domains.
1. Create an empty text file using a text editor such as notepad, and save it as htaccess.txt.
2. Edit the contents of the file. Check the following examples:
301 (Permanent) Redirect: Point an entire site to a different URL on a permanent basis. This is the most common type of redirect and is useful in most situations. In this example, we are redirecting to the “mt-example.com” domain:
# This allows you to redirect your entire website to any other domain Redirect 301 / http://mt-example.com/
302 (Temporary) Redirect: Point an entire site to a different temporary URL. This is useful for SEO purposes when you have a temporary landing page and plan to switch back to your main landing page at a later date:
# This allows you to redirect your entire website to any other domain Redirect 302 / http://mt-example.com/
Redirect index.html to a specific subfolder:
# This allows you to redirect index.html to a specific subfolder Redirect /index.html http://example.com/newdirectory/
Redirect an old file to a new file path:
# Redirect old file path to new file path Redirect /olddirectory/oldfile.html http://example.com/newdirectory/newfile.html
Redirect to a specific index page:
# Provide Specific Index Page (Set the default handler) DirectoryIndex index.html
3. Upload this file and re-name it to
- If using a text editor, be sure to save the file as plain text.
- Paths to where you should save this file can be found in this article: System paths and log file locations.
- The definitive guide on Apache directives that can be used in .htaccess files can be found here: http://httpd.apache.org/docs/mod/core.html.
More powerful URL changes with mod_rewrite
If you need to make complex changes to the way your URL displays, you should visit Using .htaccess rewrite rules. You can do things like add “www” to the beginning of your URL, redirect all requests to a subfolder but keep the rest of the URL, etc.