0

How do I permanently redirect this url using .htaccess, so that if anyone views old web page, it redirects to the new one.

For example:

http://olddomain.com/folder/AmazonASIN.html  
--> http://newdomain.com/AmazonASIN.html

http://oldexample.com/detail/B007OZNZG0.html   
--> http://newexample.com/B007OZNZG0.html
1
  • Is your site located on your own server, a webhotel or what?
    – Richard B
    May 31, 2013 at 20:22

1 Answer 1

0

Put this in your .htaccess:

Redirect 301 http://oldexample.com/detail/B007OZNZG0.html http://newexample.com/B007OZNZG0.html

UPDATE

Ok, maybe my answer was a bit short but if you only want to redirect a couple of URL's that code will work great. The thing is, if there's no real logic between your old and your new URL's I think you should do a bit of reading before you start adding redirects, it's not that hard really. See this code for example (taken from this site):

Options +FollowSymlinks
RewriteEngine on
RedirectMatch ^/$ http://www.new-site.com
Redirect 301 /old-category/old-page-1 http://www.new-site.com/new-page
Redirect 301 /old-category/old-page-2 http://www.new-site.com/new-page
Redirect 301 /old-category/old-page-3 http://www.new-site.com/new-page
Redirect 301 /old-category/old-page-4 http://www.new-site.com/new-page
Redirect 301 /old-category/old-page-5 http://www.new-site.com/new-page
RedirectMatch 301 ^/old-category-2/(.*)$ http://www.new-site.com/widgets/blue
RedirectMatch 301 ^/old-category-3/(.*)$ http://www.new-site.com/widgets/blue

The third line is redirecting your home page, the next five lines are redirecting specific URL's from old ones to new ones and the last two – RedirectMatch 301 – redirects all URL's starting with old-category-2 and old-category-3. Also, you can test your redirects by typing 302 instead of 301, 302 is not as permanent as 301.

I hope that will get you started at least!

3
  • @Richard thanks for your recommendation. I know understood. May 31, 2013 at 22:44
  • @s_ha_dum i don't have the code. :) May 31, 2013 at 22:45
  • @AlexG.Bale : What code did I ask you for?
    – s_ha_dum
    May 31, 2013 at 22:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.