Forum Moderators: phranque
// Live public directory
/home/example/www (an alias for /home/example/public_html)
// Subdomain
/home/example/ww2.example.com The htaccess at the subdomain shouldn't be impacting the live directory at all... but it does.
No one access the subdomain except for me, so there wouldn't have been any traffic on it while I was in bed.
And even if there was, there were no errors when I tested it and everything ran fine for several hours.
My only guess is that something is stuck in a loop that runs in the background, and after a few hours it locks something up?
How in the world do I track down a possible infinite loop that's not throwing an error until it crashes?
What do error logs say?
Another thing to try is, instead of renaming the htaccess, comment-out the entire thing and see if anything changes. If yes, you can start un-commenting line by line. (Voice Of Experience says the problem will be in some line that you hadn't even considered looking at, because there is absolutely zero possibility of any way on earth it could ever be causing any kind of problem.)
An alternative to the preceding--if you can do it without putting the server out of commission for another hour--is to change the offending directory's AllowOverrides settings, one by one, and see if there's some particular category of override that's causing the trouble. (This is assuming it doesn't lead to an instant 500 if the htaccess includes a rule it isn't allowed to have. I don't think that's supposed to happen, though.)
Assuming the `.htaccess` file for the subdomain is located at "/home/example/ww2.example.com/.htaccess"? And the ".htaccess" file for the main site is at "/home/example/public_html/.htaccess"? And you have no other .htaccess files? Or directives in the server config / virtual host?
The main site does not reference the subdomain in anyway?
Any server-side caching? Proxy caches? Make sure you are not seeing any cached responses... 301s are persistently cached by the browser (test with 302s and/or with the browser cache disabled).
Although did you test every possible URL combination, including the extreme edge cases and beyond?
It's quite possible for directives in .htaccess to get "stuck in a loop", but not for a few hours. An internal rewrite loop will break within a few seconds (assuming you've not increased the LimitInternalRecursion value from the default 10?).
If you are using the "N" (next) flag on the RewriteRule directive then things can break horribly if there is no way for the rule to "fail" - memory and system resources can go through the roof and bring your server to a halt. However, you would see this in a few minutes at most - unless it had been stuck in this "frozen" state for a long time - although I would think Apache would crash before too long?
What version of Apache are you running? (I'm assuming 2.4)
[Tue Apr 07 23:22:16.277433 2020] [suexec:notice] [pid 1103] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Tue Apr 07 23:22:16.293067 2020] [:notice] [pid 1103] ModSecurity for Apache/2.9.3 (http://www.modsecurity.org/) configured.
[Tue Apr 07 23:22:16.293094 2020] [:notice] [pid 1103] ModSecurity: APR compiled version="1.7.0"; loaded version="1.7.0"
[Tue Apr 07 23:22:16.293492 2020] [:notice] [pid 1103] ModSecurity: PCRE compiled version="7.8 "; loaded version="7.8 2008-09-05"
[Tue Apr 07 23:22:16.293542 2020] [:notice] [pid 1103] ModSecurity: LUA compiled version="Lua 5.1"
[Tue Apr 07 23:22:16.293562 2020] [:notice] [pid 1103] ModSecurity: LIBXML compiled version="2.9.7"
[Tue Apr 07 23:22:16.293582 2020] [:notice] [pid 1103] ModSecurity: Status engine is currently disabled, enable it by set SecStatusEngine to On.
[Tue Apr 07 23:22:18.938193 2020] [mpm_prefork:notice] [pid 1225] AH00163: Apache/2.4.41 (cPanel) OpenSSL/1.1.1f mod_bwlimited/1.4 PHP/5.6.40 configured -- resuming normal operations
[Tue Apr 07 23:22:18.938374 2020] [core:notice] [pid 1225] AH00094: Command line: '/usr/sbin/httpd'
I hate that type of debugging because it takes foreeeeeverYou could start by doing one module at a time: comment-out all the mod_rewrite lines, all the mod_dir lines, all the mod_alias lines, all the mod_authzthingummy lines. Or, heck, just the mod_rewrite lines vs. the mod_everything-else lines, since your typical htaccess is probably three-quarters mod_rewrite ;)