LiteSpeed Support Forums

LiteSpeed Support Forums (http://www.litespeedtech.com/support/forum/index.php)
-   Apache Migration/Compatibility (http://www.litespeedtech.com/support/forum/forumdisplay.php?f=24)
-   -   mod_rewrite - remove double slash from url (http://www.litespeedtech.com/support/forum/showthread.php?t=4858)

jack 03-29-2011 06:45 AM

mod_rewrite - remove double slash from url
 
Hi

These rules work fine in apache, but they don't work in litespeed (using v4.0.20):

RewriteEngine On
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]

The purpose is to remove double (or more) slashes from URLs.

I've played around with it and it seems litespeed is not matching properly in the RewriteCond.

Can someone please help me on this one?

webizen 03-29-2011 10:42 AM

LiteSpeed removes double (or more) slashes from URL internally before entering rewrite rules process. So there is no need for this. %

If you really want to use rewrite rules for this, use %{ORG_REQ_URI} instead of %{REQUEST_URI}.

jack 03-30-2011 05:29 AM

I had noticed that, sometimes, the url in the address bar got 'cleaned' from double slashes (with no rewrite rules at all). However, I haven't been able to reproduce this behaviour for a while -- it might have happened in another server.

Of course, that doesn't meen that LiteSpeed isn't cleaning them, it's just not issuing redirects, so the browser doesn't know of this.

To check this I wrote this php script (as index.php):
<?php echo 'REQUEST_URI = ' . $_SERVER['REQUEST_URI']; ?>

and when requesting these urls, i get:

http://my.domain/a//index.php --- REQUEST_URI = /a//index.php
http://my.domain/a/b/index.php --- REQUEST_URI = /a/b/index.php
http://my.domain/a/b --- REQUEST_URI = /a/b/
http://my.domain/a//b --- REQUEST_URI = /a//b/

It looks like LiteSpeed is passing the original REQUEST_URI to PHP, and not the filtered one.

I then went back to fiddle with .htaccess.

To be sure the RewriteRule was being satisfied, I tried a more obvious Cond:

RewriteCond &#37;{ORG_REQ_URI} ^/a/$
RewriteRule .* http://example.com [R=301,L]

and it works! I get redirected when visiting http://my.domain/a/ (or /a because the server automatically always adds the last slash), as expected. But it doesn't redirect with my original condition.

My conclusion is that this condition isn't being matched:
RewriteCond %{ORG_REQ_URI} ^(.*)//(.*)/$

Any ideas of how can I sort this out?

I have a client getting 404s in urls with double slashes and wish to sort that out. He's using Magento.

webizen 03-31-2011 01:02 PM

please do a force reinstall from lsws version manager in admin console. the latest 4.0.20 build supports &#37;{REQUEST_URI} more like apache now.


All times are GMT -7. The time now is 09:32 AM.