set up 301 redirect from old website to new website

Discussion in 'Server Operation' started by showe1966, Sep 21, 2007.

  1. showe1966

    showe1966 Member

    I've just spent a very enjoyable 2 hours working out how to do the following.
    What I needed to do was redirect all the traffic from my old website to my new website.

    I am running ubuntu 7.04, apache 2.

    Here is what you need to do:-

    1. vi /etc/apache2/sites-enabled/000-default

    2. Change the word "none" to "all in the following line:

    NameVirtualHost *
    <VirtualHost *>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
    Options FollowSymLinks
    AllowOverride None
    </Directory>
    <Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All

    3. Add the following code at the bottom of the file:

    RewriteEngine ON
    RewriteRule /.* http://www.siteyouwanttoredirectto.com/ [R=301,L]
     
  2. falko

    falko Super Moderator Howtoforge Staff

Share This Page