LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > External Applications > Apache Migration/Compatibility > [Solved] mod_rewrite too greedy?

Reply
 
Thread Tools Display Modes
  #1  
Old 09-29-2011, 03:11 PM
dragos dragos is offline
New Member
 
Join Date: Sep 2011
Posts: 2
Cool [Solved] mod_rewrite too greedy?

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.
Reply With Quote
  #2  
Old 09-29-2011, 05:26 PM
webizen webizen is offline
LiteSpeed Staff
 
Join Date: Oct 2010
Posts: 2,338
Try the modified rules below (should be placed in LSWS vhost Rwrite):

Quote:
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:
Quote:
RewriteRule ^([^/.]+)-article/?$ /index.php?action=article&author=$1 [L]
RewriteRule ^([^/.]+)/([^/.]+)-article/?$ /index.php?action=article&author=$1&article=$2 [L]
Reply With Quote
  #3  
Old 09-30-2011, 06:51 AM
dragos dragos is offline
New Member
 
Join Date: Sep 2011
Posts: 2
Default 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.
Reply With Quote
  #4  
Old 12-01-2012, 10:06 PM
Floriarmblome Floriarmblome is offline
New Member
 
Join Date: Nov 2012
Location: Cyprus
Posts: 4
Default Solved mod_rewrite too gr

You will need to change your approach slightly to avoid having having Apache go into an infinite loop, but something like the following should work.

RewriteEngine on
RewriteBase /

RewriteRule order/. /order.php?order=1 L
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:31 AM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.