Removing trailing slashes with query strings

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

 



Hi,

I have the following rule that works well to remove trailing slashes from URLs:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ $1 [R=301,L]

This is done to prevent the non-slash URL from being treated as duplicate content with the URL with a slash.

The problem is that there are exceptions, such as when we want to add query strings to the end of a URL:

https://example.com/administrator/path/?cms_settings

I've also tried a variation, like:

https://example.com/administrator/path?cms_settings

but somehow the slash is replaced back into the URL and I don't know where it comes from.

Adding index.php to the path works properly because it's then not a directory:

https://example.com/administrator/path/index.php?cms_settings

Any ideas greatly appreciated.

Thanks,
Dave



[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