Forum Moderators: phranque

Message Too Old, No Replies

Inconsistent slash manipulation

         

thyrf

1:20 pm on Jan 20, 2008 (gmt 0)

10+ Year Member



I run Apache2 on Debian and Windows where I build my sites. Having wrote a .htaccess file to remove excess slashes and add non-existant slashes, locally it works fine. However when I upload it to my hosting the excessive slashes rewrite fails to work and keeps redirecting to the same URL typed in.


RewriteCond %{REQUEST_URI} ^[^\.]+/(/+)$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]

Apparently my host runs 'Apache 3 - <host's name>' - I've not heard of it before.

[edited by: jdMorgan at 12:38 am (utc) on Jan. 23, 2008]
[edit reason] Obscured hosting company [/edit]

jdMorgan

1:34 pm on Jan 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is the code still located in .htaccess, or did you move it to httpd.conf?
(The URLs seen by RewriteRule in httpd.conf will start with a slash.)

Also note that if the RewriteCond is met, $1 is equal to the original URL-path, so it will indeed redirect to the same URL-path.

See this old thread for double-slash removal: [webmasterworld.com...]

Jim

thyrf

3:53 pm on Jan 20, 2008 (gmt 0)

10+ Year Member



That works a treat, thanks a lot.