Redirecting your domain or any subdirectory

By adding a "Redirect" statement to your .htaccess file, you can redirect any subdomain or your whole domain to any other file or domain in the Internet.

Each "Redirect" statement contains the "Redirect" command, the location to be redirected and the target of the redirection. You may redirect your domain to some other domain you own or you may redirect requests for e.g. "/color" to a subdirectory called "/colour".

301 redirect is the best method to preserve your current search engine rankings when redirecting web pages or a web site. The code "301" means "moved permanently".

Enter a line like below to redirect your Domain (it will not redirect if there is a request for a specific sub-page):

Redirect 301 /index.html http://www.foo.com

Enter a line like below to redirect a subdirectory:

Redirect 301 /redirectthis/index.html http://foo.com/target.html

Hint: In both cases the target must be a full URL starting with http:// even if the target of the redirection is located in your domain.

Hint: Always include the index page name after a directory name.
  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

How do I turn Directory Indexing off?

Add the following to .htaccess:Options -IndexesTurn it back on:Options +Indexes 

How can I setup dynamic/custom error pages?

If you have defined your own custom Error Pages using the "Define Error Pages" tool within the...

How do I do a rewrite instead of a 302 for missing pages?

Use something like this:RewriteEngine onRewriteCond %{REQUEST_FILENAME} !index.htmlRewriteRule /*...

How do I stop off-line browsers/ robot surfers?

Try the following in .htaccess:RewriteEngine OnRewriteCond %{HTTP_USER_AGENT} ^MozillaRewriteRule...

How do I prevent spam from email harvestering?

Use the following in .htaccess:RewriteEngine onRewriteCond %{HTTP_USER_AGENT} ^Bullseye.*...