Re: mod_rewrite to fix trailing slash problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tim Gustafson wrote:
Hi,

I have a web page that works when you include the trailing slash:

http://www.foo.com/blah/

But, if you leave the trailing slash off, it does not work and you get a 403
error:

http://www.foo/com/blah

So, I tried to fix this using some mod_rewrite rules, as follows:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1/ [R,L]

But it seems that the "-d" test is always failing.  If I comment that part
out, then *everything* gets a "/" appended to the end, which of course
doesn't work.  I tried using "!-f" instead, and got similarly bad results.

I've Googled this and read lots of solutions that all look more or less like
what I've posted above, but none of them seem to actually work.

Is there something I'm missing here

It's a bad idea to rewrite in this case, since it can cause all kinds of problems with relative URLs.

Better to redirect:

Redirect permanent /blah http://www.foo.com/blah/

cheers,
Eric

--
Eric Bowman
Boboco Ltd
ebowman@xxxxxxxxx
http://www.boboco.ie/ebowman/pubkey.pgp
+35318394189/+353872801532


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux