Mod_rewrite rule consolidation

New to mod_rewrite? This is a good place to start.

Mod_rewrite rule consolidation

Postby johnnybravoh » Mon Feb 16, 2004 9:18 pm

hello all, I have the following RewriteRule in action (.htaccess) - BTW I
also have access to httpd.conf if needed...:

RewriteRule ^[sS]ubject[/]?(.*)$ /subs/subject/$1 [C]
RewriteRule /profile/([0-9]+)[/]? /sub/subject/ch_profile.php?ID=$1 [C]
RewriteRule /profile/([0-9]+)/(.*)$
/sub/subject/ch_profile.php?ID=$1&CallBackURL=$2 [L]

RewriteRule ^[oO]bject[/]?(.*) /subs/object/$1 [C]
RewriteRule /profile/([0-9]+)[/]? /sub/object/ch_profile.php?ID=$1 [C]
RewriteRule /profile/([0-9]+)/(.*)$
/sub/object/ch_profile.php?ID=$1&CallBackURL=$2 [L]

What I want to do is allow the following
http://www.mydomain.com/subject/anyfile --> http://www.mydomain.com/sub/suject/anyfile
http://www.mydomain.com/subject/profile/2 --> http://www.mydomain.com/sub/suject/ch_profile.php?ID=2
http://www.mydomain.com/subject/profile/2/blahblah --> http://www.mydomain.com/sub/suject/ch_p ... L=blahblah

The RewriteRules currently work, but it seems very inefficient.
1) Can the 3 RewriteRules for subject be combined into 1 RewriteRule????
2) Can the 2 sets of RewriteRules be combined to make a single set that
accounts for both subject, object and other possible directories under sub?


Thanks in advance for any help!

Jon Wahl
johnnybravoh
 

Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 15 guests

cron