Most Popular
Recently Added
Recently Updated

How do I redirect a domain name or page to a different location?

1. First park the additional domain name via the "parking" option in cPanel.
2. Locate the .htacces file in your public_html directory.
3. Add the following lines of text to the bottom of the text file:

SEO - 301 redirect format
Options +FollowSymlinks
RewriteEngine on
#This line below ensure https pages do not redirect
RewriteCond %{SERVER_PORT} ^80$
RewriteCond %{HTTP_HOST} !^www\.your_domain\.com$
RewriteRule ^(.*) http://www.your_domain.com/$1 [L,R=301]


Web Page Redirection:
Redirect 301 /oldpage.html http://www.the_domain.com/newpage.html


Entire Site Redirection:
Redirect 301 / http://www.the_domain.com/


Change File Extension to PHP:
RedirectMatch 301 (.*).html$ http://www.the_domain.com$1.php


Redirect to always show non-www. version

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^the_domain.com
RewriteRule (.*) http://the_domain.com/$1 [R=301,L]


Redirect to always show the www. version
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [L,R=301]


Redirect home page like index.php to directory:
Options +FollowSymLinks
RewriteEngine on
# index.php to /
RewriteCond %{THE_REQUEST} ^[A-Z]{3, 9} /.*index.php HTTP/
RewriteRule ^(.*)index.php$ /$1 [R=301,L]


This does not use .htaccess, but can be used as the text in a web page to redirect the page to another location in 10 seconds:
meta http-equiv=refresh content="10; url=http://the_domain.com/"


References:

  • An excellent discussion on redirects with examples:
    http://www.webmasterworld.com/apache/3208525.htm

Properties ID: 000099   Views: 1734   Updated: 8 years ago
Filed under: