Re: Limiting redirects with rewriterule/rewritecond

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

 





On Sun, Feb 25, 2024 at 5:29 PM Dave Wreski <dwreski@xxxxxxxxxxxxxxxxxxx.invalid> wrote:

Hi,

In my ongoing effort to reduce the number of redirects for linuxsecurity.com, I could use a bit more help. Currently we have one redirect to strip off any potential trailing slash as well as another that strips out any preceding 'www'.

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

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

The rest of our redirects are of the form:

RewriteRule ^/about/us /about [L,R=301]

Should I be combining each of these to also do the above with something like:

RewriteRule ^/about/us/? https://linuxsecurity.com/about [L,R=301]

It seems like that would reduce the number of redirects by two, but I'm unsure of what implications that would otherwise have. Maybe if I instead performed the RewriteConds without R=301 and just rewrote the URL itself? I'm not sure how that works.

Any ideas greatly appreciated.
Thanks,
Dave



Perhaps you can, but be careful about not creating loops, especially if using .htaccess files.

Also, is there a specific reason why you're not using Redirect with mod_alias instead? 

[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