Reputation: 886
I actually want to redirect my old website url to new website url.
I have made 1 redirect working properly
for example
http://www.abc-old.com/test to http://www.abc-new.com/test123
but problem is while i have multiple slug or parameters it won't work for me
like
i want to redirect
http://www.abc-old.com/test1/test2 to http://www.abc-new.com/test1
but it is redirecting like
http://www.abc-old.com/test1/test2 to http://www.abc-new.com/test1/test2
below is my code for same
Redirect 301 /test1/test2 http://www.abc-new.com/test1
Please help me to sort out this
Upvotes: 0
Views: 256
Reputation: 886
Hie Some how i solved it but still confuse why this thing happned ?
for example I have 3 URL
http://www.old.com/test1/
http://www.old.com/test1/test2
http://www.old.com/test1/test2/test3
I have created 301 redirects in .htaccess like
Redirect 301 /test1/ http://www.new.com/test1
Redirect 301 /test1/test2/ http://www.new.com/test2
Redirect 301 /test1/test2/test3 http://www.new.com/test3
in this case
while i was requesting
http://www.old.com/test1/ is redirected to http://www.new.com/test1
while
http://www.old.com/test1/test2 is redirected to http://www.new.com/test1/test2/
in this case while server execute .htaccess , instead of my second url redirection first was working and additional parameter passing test2 so it new redirect was http://www.new.com/test1/test2
I have write code like this
Redirect 301 /test1/test2/test3 http://www.new.com/test3
Redirect 301 /test1/test2/ http://www.new.com/test2
Redirect 301 /test1/ http://www.new.com/test1
and it started working. i really don't understand why my first code is not working, I have used wordpress CMS , is there any cofiguration required ?
Upvotes: 0
Reputation: 785146
You can use this rule in old host's root .htaccess:
RedirectMatch 301 "/test1/test2(/.*)?$ http://www.abc-new.com/test1$1
Upvotes: 0
Reputation: 14875
If your .htaccess file looks like / or the httpd.conf contains this it should work.
Options +FollowSymLinks
RewriteEngine on
Redirect 301 /test1/test2 http://www.abc-new.com/test1
Maybe this could be interesting.
http://www.internetmarketingninjas.com/blog/search-engine-optimization/301-redirects/
Upvotes: 1