Apache

Moderators: None (Apply to moderate this forum)
Number of threads: 150
Number of posts: 335

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
ending rewriting with mod_rewrite Posted by PrzemekG_ on 13 Nov 2007 at 2:13 PM
Hi,

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 :)



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.