You are here: Home How do I redirect my site using a .htaccess file

How do I redirect my site using a .htaccess file

Overview

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.

CAUTION: As a configuration file, .htaccess is very powerful.Even the slightest syntax error (like a missing space) can result in your content not displaying correctly or at all.Since .htaccess is a hidden system file, please make sure your FTP
client is configured to show hidden files.
This is usually an option in the program’s preferences/options.

Instructions

Create an empty text file using a text editor such as notepad, and save it as htaccess.txt.

Edit the contents of the file. Check the following examples:

Point an entire site to a different URL, such as domain.net redirected to domain.com:

Redirect index.html to a specific subfolder:

Redirect an old file to a new file path:

Redirect to a specific index page:

NOTE:

  • 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.
  • 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.

 

Leave a Reply