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

Go Back   LiteSpeed Support Forums > LiteSpeed Web Server > Install/Configuration > Problem with RewriteCond order and %n in RewriteRule

Reply
 
Thread Tools Display Modes
  #1  
Old 10-01-2006, 03:08 PM
gboudreau gboudreau is offline
Member
 
Join Date: Oct 2006
Location: Montr
Posts: 49
Default Problem with RewriteCond order and %n in RewriteRule

Hi,

Using 2.2.2 (free), with an .htaccess like this:

Code:
<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
    RewriteCond %{REQUEST_FILENAME} !/main\.php$
    RewriteRule .   -   [L]

    RewriteCond %{THE_REQUEST} \ /d/([0-9]+)-([0-9]+)/([^\/\?]+)(\?.|\ .)
    RewriteCond %{REQUEST_FILENAME} !/main\.php$
    RewriteRule .   /main.php?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3   [QSA,L]

    RewriteCond %{THE_REQUEST} \ /v/([^?]+)(\?.|\ .)
    RewriteCond %{REQUEST_FILENAME} !/main\.php$
    RewriteRule .   /main.php?g2_view=core.ShowItem&g2_path=%1   [QSA,L]

</IfModule>
If you go to a URL like http://gallery.domain.com:8088/d/5245-14/something.jpg
then the second rule gets trigerred, but the %1, %2 and %3 are empty in the RewriteRule.

Here's what the log shows:

Code:
2006-10-01 15:03:42.660	INFO	[66.130.250.120:61102-0#gallery.domain.com] [REWRITE] Cond: Match 'GET /d/5245-14/something.jpg HTTP/1.1' with pattern '\ /d/([0-9]+)-([0-9]+)/([^\/\?]+)(\?.|\ .)', result: 5
2006-10-01 15:03:42.660	INFO	[66.130.250.120:61102-0#gallery.domain.com] [REWRITE] Cond: Match '/var/www/html/gallery2/d/5245-14/something.jpg' with pattern '/main\.php$', result: -1
2006-10-01 15:03:42.660	INFO	[66.130.250.120:61102-0#gallery.domain.com] [REWRITE] Source URI: 'd/5245-14/something.jpg' => Result URI: '/main.php?g2_view=core.DownloadItem&g2_itemId=&g2_serialNumber=&g2_fileName='
2006-10-01 15:03:42.660	INFO	[66.130.250.120:61102-0#gallery.domain.com] [REWRITE] append query string 'g2_view=core.DownloadItem&g2_itemId=&g2_serialNumber=&g2_fileName='
2006-10-01 15:03:42.660	INFO	[66.130.250.120:61102-0#gallery.domain.com] [REWRITE] Last Rule, stop!
If I simply invert both RewriteCond lines like this:
Code:
    RewriteCond %{REQUEST_FILENAME} !/main\.php$
    RewriteCond %{THE_REQUEST} \ /d/([0-9]+)-([0-9]+)/([^\/\?]+)(\?.|\ .)
Then it works fine:
Code:
2006-10-01 15:01:06.148	INFO	[66.130.250.120:61078-0#gallery.domain.com] [REWRITE] Cond: Match '/var/www/html/gallery2/d/5245-14/something.jpg' with pattern '/main\.php$', result: -1
2006-10-01 15:01:06.148	INFO	[66.130.250.120:61078-0#gallery.domain.com] [REWRITE] Cond: Match 'GET /d/5245-14/something.jpg HTTP/1.1' with pattern '\ /d/([0-9]+)-([0-9]+)/([^\/\?]+)(\?.|\ .)', result: 5
2006-10-01 15:01:06.148	INFO	[66.130.250.120:61078-0#gallery.domain.com] [REWRITE] Source URI: 'd/5245-14/something.jpg' => Result URI: '/main.php?g2_view=core.DownloadItem&g2_itemId=5245&g2_serialNumber=14&g2_fileName=something.jpg'
2006-10-01 15:01:06.149	INFO	[66.130.250.120:61078-0#gallery.domain.com] [REWRITE] append query string 'g2_view=core.DownloadItem&g2_itemId=5245&g2_serialNumber=14&g2_fileName=something.jpg'
2006-10-01 15:01:06.149	INFO	[66.130.250.120:61078-0#gallery.domain.com] [REWRITE] Last Rule, stop!
Any reason for such a behavior ?
Is RewriteRule only supposed to be able to use the %n from the previous line, and no other RewriteCond lines ?

PS This is from a working Gallery 2 installation. The same Rewrite rules work fine on Apache 2, with both RewriteCond lines inverted or not.

Thanks.
__________________
- Guillaume Boudreau

Last edited by gboudreau; 10-01-2006 at 03:15 PM..
Reply With Quote
  #2  
Old 10-01-2006, 03:42 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,583
Quote:
Is RewriteRule only supposed to be able to use the %n from the previous line, and no other RewriteCond lines ?
Yes, current rewrite engine implement is like that. We will change our implementation to improve the compatibility with Apache.

Thanks for the bug report and analysis.
Reply With Quote
  #3  
Old 10-02-2006, 01:38 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,583
this problem has been fixed in our code base, will be available in next release, 2.2.3, possibly.
Reply With Quote
  #4  
Old 10-02-2006, 01:52 PM
gboudreau gboudreau is offline
Member
 
Join Date: Oct 2006
Location: Montr
Posts: 49
Thank you very much. Appreciate the fast response time.
__________________
- Guillaume Boudreau
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 03:32 PM.



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