Re: Removing trailing slashes?

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

 





On Wed, Dec 13, 2023 at 7:13 PM Dave Wreski <dwreski@xxxxxxxxxxxxxxxxxxx.invalid> wrote:

Hi,

I have a FAQ, but need some additional info I haven't been able to find. I'm trying to process links Google has indicated are 404s that never really ever existed on our site.

I have an htaccess file I'm Including with my main apache config that only contains RewriteConds. This file is processed before any of the other htaccess files that contain standard RewriteRules. This is what I'm using to strip off any trailing slashes in URLs:

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

I just want to confirm that this means none of the RewriteRules that follow should contain a trailing slash or they will not match, correct?

Some of my existing RewriteRules that were created before I realized I should be stripping off the trailing slash actually contain a trailing slash.

Perhaps I should instead be using '/?' instead of just '/' at the end of URLs?

Thanks,
Dave



If the following rules look for a trailing slash and you remove it prior, in theory it won't match.  However, remember that .htaccess files will be parsed over and over until it stops matching, so you are likely to create a rewrite loop.

What is the rationale for removing trailing slashes here? 

[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