So I raised a previous thread here.


Basically with the site behind a htpasswd (as it is a staging url) after entering the correct u/p I would get redirected to a 404 which was in fact a 401 error.

After further investigation and some support from CPanel. I understand that there is a requirement to add the following line to the htaccess file before the rewrites (in the Craft rewrites).

RewriteCond %{LA-U:REMOTE_USER} !^$

So the Craft rewrites now look like this;

# Send would-be 404 requests to Craft
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{LA-U:REMOTE_USER} !^$
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
RewriteRule (.+) index.php?p=$1 [QSA,L]

This only became an issue this week. Previously it all worked fine before this. The above solution does seem to be a fix. But I'm a little stumped as to why this is required now and was working ok before. Has anyone else come up against this?

CPanel seemed to think it wouldn't have ever worked without this line. But it did and I am sure others have it working without a need to add this.

The difficult thing is that I am unable to get a clear reason as to why this is now required and what has changed to enforce this. Over the past week a few things have occurred and so I cannot pinpoint. These updates to the server have included;

  • Updating Apache 2.2 to 2.4
  • Upgrading to easyapache 4 from easyapache 3
  • Updating Craft after the latest releases.

If anyone can shed any additional light on this it would be useful. Also if anyone can confirm if they also need to include the RewriteCond %{LA-U:REMOTE_USER} !^$ into their htaccess.

  • My guess would be the Apache, upgrade, but I don't know for sure. Seems like we can delete craftcms.stackexchange.com/questions/16741/… now, since this is a follow-up with more information, no? – Brad Bell Sep 12 '16 at 0:48
  • Yes please delete. Any ideas where it what I might need to look at? It's driving me mad this one. Can't find anything similar or any real difference after the upgrade. – Terry Upton Sep 12 '16 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.