Forum Moderators: phranque
I'm having issues with a .htaccess 301 redirect.
I would like to redirect:
http://www.exmaple.com/hei-by-alfred-sung-for-men-100ml-edt-spray.html to
http://www.example.com/mens-aftershave/alfred-sung/hei-100ml-edt-spray.html The code being used is:
Redirect 301 /([\w-]+)-by-([\w-]+)-for-men-([\w-]+)\.html http://www.example.com/mens-aftershave/$2/$1-$3.html
I need any page that shows '-for-men-' in the old url to redirect to '/mens-aftershave/' then show the brand in folder format (alfred-sung/), then the product name (hei) then the remaining details (100ml-edt-spray).
Currently, the 301 is being ignored (or redirecting to the wrong page) and I'm being redirected a 404 error page.
Thanks in advance for any help.
[edited by: jdMorgan at 3:12 pm (utc) on May 7, 2009]
[edit reason] example.com [/edit]
If that is the case, replace each instance of "[\w-]+" with "[_0-9A-Za-z\-]+".
Refer to the Apache mod_rewrite documentation for your server version, and use only the regular-expressions tokens that are documented as supported on your server.
Also, for the sake of efficiency, add an [L] flag to each of your rules, unless you know why you don't want to use it.
Jim