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

Go Back   LiteSpeed Support Forums > LiteSpeed Web Server > General > Rewrite Problem

Reply
 
Thread Tools Display Modes
  #1  
Old 03-20-2007, 08:58 AM
Jetro Jetro is offline
Member
 
Join Date: Aug 2005
Location: Poland
Posts: 18
Default Rewrite Problem

After upgrading lsws from 2.2.6 to 3.0, one of virtualhosts, that uses rewrite rules in htaccess file, stopped work correctly. In server log i see:
ERROR [85.128.x.x:44929-0#hmt.pl] Maximum number of redirect reached.

.htacces:
RewriteEngine On

RewriteCond %{HTTP_HOST} ^endemit\.hmt\.pl [NC]
RewriteRule (.*) /_endemit/$1 [L]
RewriteCond %{HTTP_HOST} ^projekt\.hmt\.pl [NC]
RewriteRule (.*) /_projekt/$1 [L]
RewriteCond %{HTTP_HOST} ^klasad\.hmt\.pl [NC]
RewriteRule (.*) /_klasad/$1 [L]
RewriteCond %{HTTP_HOST} ^www.hmt.pl$
RewriteRule ^(.*)$ http://hmt.pl/ [R=301,L]

ErrorDocument 404 http://hmt.pl/error.php?error=404
ErrorDocument 400 http://hmt.pl/error.php?error=400
ErrorDocument 403 http://hmt.pl/error.php?error=403
ErrorDocument 500 http://hmt.pl/error.php?error=500
Reply With Quote
  #2  
Old 03-20-2007, 09:56 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Can you setup a test server with rewrite logging enabled. This way, we can figure out what causes the loop of redirection.
Reply With Quote
  #3  
Old 03-20-2007, 10:39 AM
Jetro Jetro is offline
Member
 
Join Date: Aug 2005
Location: Poland
Posts: 18
2007-03-20 18:29:08.186 INFO [xxx:4006-0#hmt.pl] [REWRITE] strip rewrite base: '/' from URI: '/'
2007-03-20 18:29:08.186 INFO [xxx:4006-0#hmt.pl] [REWRITE] Rule: Match '' with pattern '(.*)', result: 2
2007-03-20 18:29:08.186 INFO [xxx:4006-0#hmt.pl] [REWRITE] Cond: Match 'endemit.hmt.pl' with pattern '^endemit\.hmt\.pl', result: 1
2007-03-20 18:29:08.187 INFO [xxx:4006-0#hmt.pl] [REWRITE] Source URI: '' => Result URI: '/_endemit/'
2007-03-20 18:29:08.187 INFO [xxx:4006-0#hmt.pl] [REWRITE] Last Rule, stop!
2007-03-20 18:29:08.187 INFO [xxx:4006-0#hmt.pl] [REWRITE] strip rewrite base: '/' from URI: '/_endemit/'
2007-03-20 18:29:08.187 INFO [xxx:4006-0#hmt.pl] [REWRITE] Rule: Match '_endemit/' with pattern '(.*)', result: 2
2007-03-20 18:29:08.187 INFO [xxx:4006-0#hmt.pl] [REWRITE] Cond: Match 'endemit.hmt.pl' with pattern '^endemit\.hmt\.pl', result: 1
2007-03-20 18:29:08.187 INFO [xxx:4006-0#hmt.pl] [REWRITE] Source URI: '_endemit/' => Result URI: '/_endemit/_endemit/'
2007-03-20 18:29:08.187 INFO [xxx:4006-0#hmt.pl] [REWRITE] Last Rule, stop!
2007-03-20 18:29:08.187 INFO [xxx:4006-0#hmt.pl] [REWRITE] strip rewrite base: '/' from URI: '/_endemit/_endemit/'
2007-03-20 18:29:08.187 INFO [xxx:4006-0#hmt.pl] [REWRITE] Rule: Match '_endemit/_endemit/' with pattern '(.*)', result: 2
2007-03-20 18:29:08.187 INFO [xxx:4006-0#hmt.pl] [REWRITE] Cond: Match 'endemit.hmt.pl' with pattern '^endemit\.hmt\.pl', result: 1
2007-03-20 18:29:08.187 INFO [xxx:4006-0#hmt.pl] [REWRITE] Source URI: '_endemit/_endemit/' => Result URI: '/_endemit/_endemit/_endemit/'

........

2007-03-20 18:29:08.188 INFO [xxx:4006-0#hmt.pl] [REWRITE] strip rewrite base: '/' from URI: '/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/'
2007-03-20 18:29:08.188 INFO [xxx:4006-0#hmt.pl] [REWRITE] Rule: Match '_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/' with pattern '(.*)', result: 2
2007-03-20 18:29:08.188 INFO [xxx:4006-0#hmt.pl] [REWRITE] Cond: Match 'endemit.hmt.pl' with pattern '^endemit\.hmt\.pl', result: 1
2007-03-20 18:29:08.188 INFO [xxx:4006-0#hmt.pl] [REWRITE] Source URI: '_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/' => Result URI: '/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/_endemit/'
2007-03-20 18:29:08.188 INFO [xxx:4006-0#hmt.pl] [REWRITE] Last Rule, stop!
2007-03-20 18:29:08.188 ERROR [xxx:4006-0#hmt.pl] Maximum number of redirect reached.
Reply With Quote
  #4  
Old 03-20-2007, 05:45 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
There is a subtle change in rewrite engine in release 3.0 that rewritten URL may be processed again.

As you can tell from the log file, the URL has been rewritten again and again by prepending "/_endemit/" repeatedly, you may need to add a rewrite condition to prevent that from happening.
Reply With Quote
  #5  
Old 03-25-2007, 04:42 AM
Jetro Jetro is offline
Member
 
Join Date: Aug 2005
Location: Poland
Posts: 18
But how? I added:
RewriteOptions MaxRedirects=1

And there's still problem with infinite loops and internal error 500.
Reply With Quote
  #6  
Old 03-26-2007, 11:43 AM
Jetro Jetro is offline
Member
 
Join Date: Aug 2005
Location: Poland
Posts: 18
Problem solved

RewriteCond %{HTTP_HOST} ^klasad.hmt.pl [NC]
RewriteCond %{CURRENT_URI} !^_klasad
RewriteRule (.*) /_klasad/$1 [L]

But i lost a couple of time, because as You can see at logs in my previous posts, CURRENT_URI don't has "/" at start of the string. I thought that URI always should begin at "/". Correct me if this is this not a bug.
Reply With Quote
  #7  
Old 03-26-2007, 01:27 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
The leading '/' got choped off for rewrite rules in a .htaccess file, it is called "rewrite base" in Apache.
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 07:12 AM.



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