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

Go Back   LiteSpeed Support Forums > LiteSpeed Web Server > Bug Reports > [Solved]Rewrite not working as expected for static external redirects

Reply
 
Thread Tools Display Modes
  #1  
Old 11-23-2010, 04:02 AM
Marcus Marcus is offline
Senior Member
 
Join Date: Feb 2007
Posts: 69
Default [Solved]Rewrite not working as expected for static external redirects

Hi,

I'm trying to do an external rewrite like :

http://example.com/example_url => http://other.server.com/http://example.com/example_url

The rewrite rule I have tried is :

RewriteRule .* http://other.server.com/http://%{SERVER_NAME}%{REQUEST_URI} [R,L]

but this just hangs. The error log shows :

Code:
2010-11-23 13:07:18.104 [INFO] [127.0.0.1:55432-0#proxy-login-redirect] [REWRITE] Rule: Match '/test' with pattern '.*', result: 1
2010-11-23 13:07:18.104 [INFO] [127.0.0.1:55432-0#proxy-login-redirect] [REWRITE] Source URI: '/test' => Result URI: 'http://other.server.com/http://example.com/test'
2010-11-23 13:07:18.104 [INFO] [127.0.0.1:55432-0#proxy-login-redirect] [REWRITE] Last Rule, stop!
I have tried other replacements in the RewriteRule directive which do not work (they just hang, and give similar error log messages to above).

RewriteRule .* http://other.server.com/?u=http://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteRule .* http://other.server.com/http://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteRule .* http://other.server.com%{REQUEST_URI} [R,L]
RewriteRule ^(.*)$ http://other.server.com/u=http://%{SERVER_NAME}$1 [R,L]
RewriteRule ^(.*)$ http://other.server.com/$1 [R,L]

These rules do work though :

RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteRule .* http://%{SERVER_NAME}:8000%{REQUEST_URI} [R,L]

(where 8000 can be any valid port).

It appears that the problem might be when the redirected server name is statically defined rather than generated at runtime (though I'd need to test more scenarios to confirm that).

Note : these rules are input into the 'Rewrite' section at the virtual host level. I have not tried them in other contexts.

Note also : the error log entries (all log level 9) are identical to the one displayed above (except for the resulting URI), whether the external redirect is successful or not.

Litespeed version : 4.0.17 Standard.

Thanks for looking into this.

Last edited by NiteWave; 11-23-2010 at 04:51 PM..
Reply With Quote
  #2  
Old 11-23-2010, 07:47 AM
NiteWave NiteWave is offline
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,293
Quote:
these rules are input into the 'Rewrite' section at the virtual host level.
for
Quote:
RewriteRule .* http://other.server.com/http://%{SERVER_NAME}%{REQUEST_URI} [R,L]
how about:
Quote:
RewriteRule /.* http://other.server.com/http://%{SERVER_NAME}%{REQUEST_URI} [R,L]
Reply With Quote
  #3  
Old 11-23-2010, 07:55 AM
Marcus Marcus is offline
Senior Member
 
Join Date: Feb 2007
Posts: 69
No difference. It still doesn't work.
Reply With Quote
  #4  
Old 11-23-2010, 08:29 AM
NiteWave NiteWave is offline
LiteSpeed Staff
 
Join Date: Sep 2009
Posts: 2,293
I tried by
Quote:
RewriteRule /.* http://google.com/http://%{SERVER_NAME}%{REQUEST_URI} [R,L]
looks like it's working
Reply With Quote
  #5  
Old 11-23-2010, 09:59 AM
Marcus Marcus is offline
Senior Member
 
Join Date: Feb 2007
Posts: 69
Yes,

The problem was unrelated to LS - it was because I was testing in a browser, and the page I was trying to redirect to hasn't been created yet. I tried using curl, and it worked as expected.

Sorry to have taken up your time. Thanks for your help.

Marcus.
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 04:46 AM.



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