Knowledgebase
How to redirect a website
Posted by Barry Tarbet on 24 August 2006 08:00 PM

we offer several ways for a web site redirection :

1) use the H-Sphere redirect http://hsphere.parallels.com/docs/3.5.0/user/html/index.htm

2) Forward a web page URL or home page using the following web page with the "Refresh" directive:
This commands the browser to refresh the page with the new specified URL.

Web site redirection methods:

  1. One can forward a web page URL or home page using the following web page with the "Refresh" directive:
    <META HTTP-EQUIV="Refresh" Content="0; URL=http://www.company.com/dir1/">
    
    This commands the browser to refresh the page with the new specified URL.

     

  2. Use a CGI script to forward a home page: (mod_cgi)
    File: httpd.conf
    ScriptAlias / /var/www/cgi-bin/redirect-script/
    
    File: /var/www/cgi-bin/redirect-script
    #!/usr/bin/perl
    
    print "Status: 301 Moved\r\n" .
          "Location: http://www.new-domain.com/\r\n" .
          "\r\n";
    

     

  3. Use ASP method to forward
<%
Response.Redirect "http://www.w3schools.com"
%>

 

Apache 301 redirect using the .htacess file:

1) If one wants to permanently forward an entire web site to a new URL or forward a single page permanently and have the search engines update their database, one should use a 301 redirect. This may redirect to a new server or to inself but to a different domain. This tutorial shows how. This method is a variation of using the mod_alias redirection shown above except that it allows the customer to redirect themselves by providing a .htacess file themselves.


File: .htaccess Create a file /yourdomain.com/.htaccess in that directory of the domain to be forwarded that looks something like this:

  • Redirect entire domain:
    Redirect 301 /  http://www.new-domain.com/
    
    Note: The use of the "/" at the end of the redirected domain. This is necessary so that http://www.old-domain.com/page1.html will be redirected to http://www.new-domain.com/page1.html.
    OR
  • Redirect specified pages:
    Redirect 301 /old-page-1.html  http://www.newdomain.com/new-page-1.html
    Redirect 301 /old-page-2.html  http://www.newdomain.com/new-page-2.html
    

    You may use the following directives:
  • 301: permanent
  • 302: temp
  • 303: seeother
  • 410: gone

For example:
Redirect permanent /  http://www.newdomain.com/
If an incorrect directive is used in the httpd.conf or .htaccess file it will result in a server error. Check your log files: /var/log/httpd/error_log.

 


HTTP 1.1 Redirect codes:

 

HTTP CodeStatusDescription
301 permanent The resource has permanently moved
302 temp The resource has temporarily moved
303 seeother The resource has been replaced and refer to new resource
305 UseProxy Use proxy to access site
307 Temp The resource has temporarily moved
410 Tegone The resource has permanently removed

See RFC 2616 HTTP/1.1 protocol - Chapter 10.3

 

 

If your still experiencing difficulties, please submit a support ticket include detailed description how to duplicate problem

 

Leave a comment below, if there is some aspect of this article you would like to see changed or improved.

 

 

(743 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).