mikely
asked on
mod-rewrite - Can I use a RewriteCond backreference in the PATTERN for the subsequent RewriteRule
While this works as I'd expect (rewrites http://www.whatever.com/BLAH to http://www.whatever.com/test.php):
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/BLAH/ [NC]
RewriteRule ^BLAH/$ test.php [NC,L]
, I was half expecting this to work (both http://www.whatever.com/BLAH and http://www.whatever.com/SCHMLAH being rewritten to http://www.whatever.com/test.php):
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/(BLAH|SCHMLAH)/ [NC]
RewriteRule ^%1/$ test.php [NC,L]
I have tested that the backreference from the RewriteCond contains a value by tracing it in the substitution of the RewriteRule. It seems that i cannot use a backreference from a RewriteCond in the PATTERN of the RewriteRule.
Is this the case or am I doing something wrong?
Cheers
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/BLAH/ [NC]
RewriteRule ^BLAH/$ test.php [NC,L]
, I was half expecting this to work (both http://www.whatever.com/BLAH and http://www.whatever.com/SCHMLAH being rewritten to http://www.whatever.com/test.php):
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/(BLAH|SCHMLAH)/ [NC]
RewriteRule ^%1/$ test.php [NC,L]
I have tested that the backreference from the RewriteCond contains a value by tracing it in the substitution of the RewriteRule. It seems that i cannot use a backreference from a RewriteCond in the PATTERN of the RewriteRule.
Is this the case or am I doing something wrong?
Cheers
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I hope that Cheat Sheet can help you as much as it has helped me out.