ending rewriting with mod_rewrite - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

ending rewriting with mod_rewrite

PrzemekG_PrzemekG_ Posts: 595Member

I have a problem with mod_rewrite.

I have two (or more) rules, where URL after rewriting with the first one matches the next rule.

RewriteRule ^data/([a-zA-Z0-9_]+)/([a-zA-Z0-9_.]+)$ modules/$1/data/$2 [L,E=D:1]
RewriteRule ^layout/([a-zA-Z0-9_.,-/]+)$ layout/$1 [L,E=D:1,QSA]
RewriteCond %{ENV:D} ^1$
RewriteRule ^([a-zA-Z_][a-zA-Z_0-9]+)$ app.php?_=$1 [L,E=D:1,QSA]
RewriteCond %{ENV:D} ^1$
RewriteRule ^([a-zA-Z_][a-zA-Z_0-9]+)/([a-zA-Z0-9_.,-/]+)$ app.php?_=$1&path=$2 [L,E=D:1,QSA]
RewriteCond %{ENV:D} ^1$
RewriteRule ^$ app.php [L,E=D:1,QSA]

I had to add RewriteConds so the first rewritten rule (to module/...) doesn't get caught in later rules.
Is there a better way to do that ?

Oh, I'm not expert on regular expressions, so they arn't as pretty as they could be :)
Sign In or Register to comment.