Home > .htaccess, php > Redirect old pages to new domain

Redirect old pages to new domain

June 14th, 2007

Hi,

A simple way to redirect ur old pages to new pages is just do the simple 301 redirection in ur .htacess. assume that you have a domain and you have shifted the domain to a new domain and now you want to redirect all the request on old domain to ur new domain.

This can be done just by writing 2 lines of code in .htaccess and this will work only if the mod_rewrite module is installed.

Options +FollowSymlinks
RewriteEngine on
rewritecond *.olddomain.com [nc]
rewriterule ^(.*)$ http://www.newdomain.com/$1 [r=301,nc]

The above code will work if the path are same on the both domain.

If the paths are different and you want to redirect all the request to new home page on new domain just remove the $1 in the above code.

Options +FollowSymlinks
RewriteEngine on
rewritecond *.olddomain.com [nc]
rewriterule ^(.*)$ http://www.newdomain.com/ [r=301,nc]

Thanks

–Asif–

.htaccess, php

  1. No comments yet.
  1. No trackbacks yet.

Powered by Yahoo! Answers