Reputation: 32119
I have this rewrite rule
RewriteRule (.*)/([^/\.]+).css$ include/style/styleRedir.php?css=$2.css [L,NC]
which matches thing like:
somefolder/foo.css
and rewirites them to:
include/style/styleRedir.php?css=foo.css
however it won't match:
foo.css
So I tried changing it to:
RewriteRule (.*)(/?)([^/\.]+).css$ include/style/styleRedir.php?css=$3.css [L,NC]
but then it would rewrite to:
include/style/styleRedir.php?css=.css
So how could I make this RewriteRule so it can rewrite foo.css to include/style/styleRedir.php?css=foo.css
Upvotes: 0
Views: 509
Reputation: 34650
I don't have Apache installed to test, but have you tried adding the /? to the first grouping?
RewriteRule (.*/?)([^/\.]+).css$ include/style/styleRedir.php?css=$2.css [L,NC]
Alternately, why not 2 rules?
RewriteRule (.*)/([^/\.]+).css$ include/style/styleRedir.php?css=$2.css [L,NC]
RewriteRule /?([^/\.]+).css$ include/style/styleRedir.php?css=$1.css [L,NC]
Upvotes: 4