Coastal Web
10-16-2009, 05:23 PM
Hi everyone, l'm in the process of cleaning up one of our servers, and in doing so l'm consolidating several root level directories into sub directories; and in setting up the htaccess file for the 301 redirects l've come up with a few questions.
Forst off here are a few redirects that are being moved from root, to /pages>:
new_carissa_poster -> /pages/new_carissa_poster
medical_guide -> /pages/medical_guide
elections -> /pages/elections
And here is the htaccess code l'm using for the redirect (they work fine):
RewriteRule ^new_carissa_poster(.*) "/pages/new_carissa_poster$1" [R=301,L]
RewriteRule ^medical_guide(.*) "/pages/medical_guide$1" [R=301,L]
RewriteRule ^elections(.*) "/pages/elections$1" [R=301,L]
My question is, is there a way to consolidate these into one rule, something like:
RewriteRule ^(new_carissa_poster|medical_guide|elections)(.*) "/page/$1/$2" [R=301,L]
My problem is the "/pages/$1/$2" bit, l'm not sure what to do here. Any help would be great!
Also l've gotten sub directories that are being moved deeper, for instance:
/pages/bay_appliance -> /pages/expired/bay_appliance
/pages/coos_bay_toyota -> /pages/expired/coos_bay_toyota
So my rewrite rules are:
RewriteRule ^pages/bay_appliance(.*) "/pages/expired/bay_appliance$1" [R=301,L]
RewriteRule ^pages/coos_bay_toyota(.*) "/pages/expired/coos_bay_toyota$1" [R=301,L]
I'd like to do the same thing as above (consolidate the rule into one single rule) but l'm hitting a wall on doing so and can't figure it out. If this is possible please let me know guys!
Thanks!
Forst off here are a few redirects that are being moved from root, to /pages>:
new_carissa_poster -> /pages/new_carissa_poster
medical_guide -> /pages/medical_guide
elections -> /pages/elections
And here is the htaccess code l'm using for the redirect (they work fine):
RewriteRule ^new_carissa_poster(.*) "/pages/new_carissa_poster$1" [R=301,L]
RewriteRule ^medical_guide(.*) "/pages/medical_guide$1" [R=301,L]
RewriteRule ^elections(.*) "/pages/elections$1" [R=301,L]
My question is, is there a way to consolidate these into one rule, something like:
RewriteRule ^(new_carissa_poster|medical_guide|elections)(.*) "/page/$1/$2" [R=301,L]
My problem is the "/pages/$1/$2" bit, l'm not sure what to do here. Any help would be great!
Also l've gotten sub directories that are being moved deeper, for instance:
/pages/bay_appliance -> /pages/expired/bay_appliance
/pages/coos_bay_toyota -> /pages/expired/coos_bay_toyota
So my rewrite rules are:
RewriteRule ^pages/bay_appliance(.*) "/pages/expired/bay_appliance$1" [R=301,L]
RewriteRule ^pages/coos_bay_toyota(.*) "/pages/expired/coos_bay_toyota$1" [R=301,L]
I'd like to do the same thing as above (consolidate the rule into one single rule) but l'm hitting a wall on doing so and can't figure it out. If this is possible please let me know guys!
Thanks!