views:

55

answers:

3

hi to all,

i have a site in php. now i want to redirect my older site url to new url.

whenever user enter my old site url in address bar using browser url must be redirect to my new url.

How can i do this using .htaccess file.

Thanks in advance.

A: 

Redirect http://oldsite.com http://newsite.com

Alexander.Plutov
-1 for being plain wrong
unbeli
+1  A: 

If you have a page by page mapping you can do it like this:

RewriteEngine on
RewriteRule index.php http://www.example.com/index.asp [R=301]
RewriteRule prods.html http://www.example.com/products.xhtml [R=301]

The first part ex, index.php is the local name index.asp is the remote name, [R=301] Means you are using a 301 as prescribed in RFC2616 meaning the file has moved permanently.

If all the files map perfectly in some way to another server you can do it like this:

RewriteEngine on
RewriteRule (.*) http://www.example.com/$1 [R=301]

Here you capture all requests and say that the file can now be found on example.com whatever it is called.

Best of luck.

Kristoffer S Hansen
@Kristoffer S Hansen - hi this helps me a lot thanks.. +2
Sanjay
A: 

or edit your index.php at your old site

<php  
header('Location: http://newsite.com');
?>
Jordy
@jordy -- i like your way but this is not standard format.but this is also possible way so only +1
Sanjay