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

Go Back   LiteSpeed Support Forums > External Applications > Apache Migration/Compatibility > mod_rewrite - remove double slash from url

Reply
 
Thread Tools Display Modes
  #1  
Old 03-29-2011, 06:45 AM
jack jack is offline
New Member
 
Join Date: Mar 2011
Posts: 7
Default 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?
Reply With Quote
  #2  
Old 03-29-2011, 10:42 AM
webizen webizen is offline
LiteSpeed Staff
 
Join Date: Oct 2010
Posts: 2,337
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}.
Reply With Quote
  #3  
Old 03-30-2011, 05:29 AM
jack jack is offline
New Member
 
Join Date: Mar 2011
Posts: 7
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.

Last edited by jack; 03-30-2011 at 05:30 AM.. Reason: Typo...
Reply With Quote
  #4  
Old 03-31-2011, 01:02 PM
webizen webizen is offline
LiteSpeed Staff
 
Join Date: Oct 2010
Posts: 2,337
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.
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 05:48 AM.



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