Forum Moderators: phranque

Message Too Old, No Replies

301 redirect

301 redirect

         

Prithvi

10:49 am on Apr 13, 2012 (gmt 0)

10+ Year Member



Hi Guys,

I am facing a problem in redirecting a old url to new url.

For eg.

I want to redirect

http://olddomain.com/ and [olddomain...] param)

to

http://www.newdomain.com/ and [newdomain.com...] param)

So what I was doing

RewriteCond %{HTTP_HOST} ^.*olddomain.com [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]


It works for [olddomain.com...] and it redirects to [newdomain.com...] but when there is query string it doesn't take to the right url.

so [olddomain...] param) doesn't redirect to [newdomain.com...] param).I guess there is something with (.*).Do I need to put it at the end as well but not sure where to put.

I am really lost.Please suggest.

Thanks in advance.

Raj
Edit/Delete Message

Paul Bedford

12:13 pm on Apr 13, 2012 (gmt 0)

10+ Year Member



Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]


Is what I use on a couple of sites.

Prithvi

1:04 pm on Apr 13, 2012 (gmt 0)

10+ Year Member



Hi Paul,

Thanks for your suggestion.

So if the url is [olddomain.com...] then it will redirect to [newdomain.com...] The url is dynamic so sometimes instead of abc it can be xyz.

Thanks,

Raj