[Solved] mod_rewrite too greedy?

#1
I have this rule into LSWS:

RewriteRule /([^/.]+)-article/?$ /index.php?action=article&author=$1 [L]
RewriteRule /([^/.]+)/([^/.]+)-article/?$ /index.php?action=article&author=$1&article=$2 [L]

If published in this order, will trigger 1st rule instead of 2nd rule for:
/doyle-conan/sherlock-article/

If I reverse the order, all works fine. Unfortunately that's not an acceptable solution.

This does work without a problem on apache (in this natural order I wrote here). Any help will be greatly appreciated.
 

webizen

Well-Known Member
#2
Try the modified rules below (should be placed in LSWS vhost Rwrite):

RewriteRule ^/([^/.]+)-article/?$ /index.php?action=article&author=$1 [L]
RewriteRule ^/([^/.]+)/([^/.]+)-article/?$ /index.php?action=article&author=$1&article=$2 [L]
Use the followings (leading "/" removed) for .htaccess rerwite:
RewriteRule ^([^/.]+)-article/?$ /index.php?action=article&author=$1 [L]
RewriteRule ^([^/.]+)/([^/.]+)-article/?$ /index.php?action=article&author=$1&article=$2 [L]
 
#3
worked great [SOLVED]

Thank you. It was the obvious solution but I could not see it.

I did not knew you support .htaccess in LSWS so I've copied rules from .htaccess and I've spent some time until I've figured out that used in LSWF needed the / in front of the rule in order to work - but I've missed the ^.

One more time, thank you for "opening my eyes" - I've blamed greedy regexp not my eyes.
 
Top