redirecting question

Discuss practical ways rearrange URLs using mod_rewrite.

redirecting question

Postby andrew » Sat Jun 04, 2005 12:28 pm

Hello, I have a some redirecting to do and would like to use mod_rewrite. I've looked around on google and this forum but can't find the same application.

http://www.domain.com/i-ABC1234.html

redirect to

http://www.domain.com/inventory/ABC1234/

I think I could use something like:

RewriteEngine on
RewriteRule ^i-ABC1234\.html$ /inventory/ABC1234/ [R=301,L]

But I would have to make a RewriteRule for every page. How can I make all the i-AGVS7452.html pages redirect to the corresponding path
Thanks for any help! :)

Oh I've figured out that the "R" means redirect and 301 means permanent... what is the L?
andrew
 

Postby andrew » Mon Jun 06, 2005 4:28 pm

i've tried to figure it out from previous examples but it's not easy when you don't understand the language.

RewriteRule ^i-$\.html /inventory/$1 [R=301,L]

RewriteRule ^/inventory/([^/]+)? /i-.$1.html [R=301,L]

any help?
andrew
 

Postby andrew » Mon Jun 06, 2005 4:35 pm

Think i've got it..

RewriteEngine on
RewriteRule ^i-([A-Z]+[0-9]+)\.html$ /inventory/$1/ [R=301,L]

seems to work but are there any mistakes or problems?

would it hurt to use ([A-Z]+[a-z]+[0-9]+) just in case there are lower case file names?

Thanks
andrew
 

Postby Caterham » Thu Jun 09, 2005 10:46 am

would it hurt to use ([A-Z]+[a-z]+[0-9]+) just in case there are lower case file names?
use

([a-zA-Z0-9]+)
=> just one single character class
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby andrew » Tue Jun 14, 2005 4:44 pm

Thank you sir, that's exactly what I was looking for.

Sorry to see you leave, you've been a great help to a lot of us. Thanks! :)
andrew
 


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 26 guests

cron