Mod Rewrite 301 Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cesarcesar
Forum Contributor
Posts: 111
Joined: Mon Oct 18, 2004 3:28 pm

Mod Rewrite 301 Help

Post by cesarcesar »

I need to 301 some links. I have been getting my knees wet with ModRewrite for a while now, but this one seems to throw me. The format I'm looking for is below.

Old - http://www.sitename.com/big-widget/blue/2.html

New - http://www.sitename/blue-big-widgets/2.html

Two thinks to note, I have added a (s) to the end of widgets. As well as the 2.html will be any number between 1-100 depending on the page.

Thanks for your help in figuring this out.
cesarcesar
Forum Contributor
Posts: 111
Joined: Mon Oct 18, 2004 3:28 pm

Re: Mod Rewrite 301 Help

Post by cesarcesar »

The solution I ended up going with was

Code: Select all

RewriteRule ^(big-widget)/([^/\.]+)/(.*) $2-$1es/$3 [R=301,L]
A more dynamic version is

Code: Select all

RewriteRule ^([^/\.]+)/([^/\.]+)/(.*) $2-$1es/$3 [R=301,L]
Post Reply