On Fri, Aug 2, 2024 at 10:18 AM Dave Wreski <dwre...@guardiandigital.com.invalid> wrote:
> Hi, > > I have a rewrite that's creating a loop because the origin is contained in > the final destination. I know it then is processed again by the .htaccess > in the document root, but I don't understand why or how to stop it. What's > the solution here? > > RewriteRule ^/features/linux-malware-the-truth-about-this-growing-threat$ > https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat-updated > [L,R=301,END] > > I've tried variations of the above but it always creates a loop. > > $ wget -O /dev/null > https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat > 2>&1|grep -E 'Location|HTTP' > HTTP response 302 [ > https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat > ] > HTTP response 301 [ > https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat-updated > ] > HTTP response 200 [https://linuxsecurity.com//features] > > Thanks, > Dave > > > If you don't depend on mod_rewrite for anything else, I would recommend using RedirectMatch instead. That rule on its own won't loop, unless you have other conflicting directive or rewrite rules. If you must use mod_rewrite, then enabling the rewrite log will help you pinpoint the source of the loop.