Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have one .htaccess file doing this:

RewriteRule ^system(.*)$ /system/app/$1 [QSA,L]

...and then underneath /system/app, I have another .htaccess file doing this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [QSA]

So, when you connect to /system and /system/login, it should be calling /system/app/index.php in both cases.

On most of the hosting plans I'm working with, this works. But on a few customer hosting plans, I'm getting an unusual result. That unusual result is that I can connect to /system just fine and index.php loads, but if I connect to /system/login, I get a 404. I even simplied /system/app/index.php and made it simply do:

<?php print_r($_SERVER);

...but it only shows a result on /system, and shows a 404 if /system/login. Now, switch to another guy's hosting plan, and it works fine -- it's only on some hosting plans.

What do you think might be the problem? Is it mod_security? Is it MultiViews turned on? Is it a particular version of Apache causing this? Is it a bug in Apache? I'm baffled.

EDIT: I'm almost wondering if there's a new Apache configuration that will only let you have one .htaccess file in the root directory, or won't let you have one .htaccess file load and then call another .htaccess file in a subfolder.

EDIT: WAIT before you try to close this question as being "too localized". Listen to me a minute. If this is a brand new option in Apache or cPanel that one can turn on, creating this problem, or is a new mod_security thing, don't you think it will be a problem that will affect A TON OF PEOPLE, not just those on HostGator?

share|improve this question

closed as too localized by Tom O'Connor, mdpc, Michael Hampton, Scott Pack, Ward Dec 15 '12 at 4:51

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Not sure whether this will be causing the problem, but your slashes in the first rule are unbalanced - /system/login will get redirected to /system/app//login; maybe something's choking on the double slash? – nickgrim Dec 14 '12 at 11:05
Good point. I removed the extra slash before the $1 when I found that. Still, no good. – ServerChecker Dec 14 '12 at 14:52
To all the haters out there trying to get this thing closed. You say it's too localized. Okay, but if this is a brand new option in Apache that people can flip on and it can create a problem for people not just on HostGator but on other hosting plans as well, then you have closed a ticket that could have helped a whole lot of people. Gee, thanks. :( – ServerChecker Dec 14 '12 at 17:13
@ServerChecker There's no mechanism, new or otherwise, to place a limit on the effective depth a rewrite rule; it either applies or it doesn't. Are you sure it's not something simple, like you have a /system/login directory that exists on the system where it's not working, which is causing the RewriteConds to not redirect? Do you have any way to access the mod_rewrite log? – Shane Madden Dec 15 '12 at 8:31
In this particular situation, I think mod_security was shutting us down. I had 3 customers delete their addon domains on HostGator and start over, and then it started working again. I hate that mod_security. – ServerChecker Dec 17 '12 at 14:36