0

I must have discovered a bug in Apache! Because I have the wierdest issue with my webhost. I cannot access a folder named admin. It works in one virtualhost but not the other. (Same hosting account)

/.htaccess

<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine on
  RewriteBase /

  # No logic for resolved paths
  RewriteCond %{REQUEST_FILENAME} -d [OR]
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -l
  RewriteRule ^ - [L]

  RewriteRule .* index.php [L]
</IfModule>

/admin/.htaccess:

AuthType Basic
AuthName "Restricted Area"
AuthUserFile /home/user/domains/mydomain.com/public_html/admin/.htpasswd
Require valid-user

Resolving http://www.mydomain.com/admin/index.php I get 404 not found. If I remove the admin/.htaccess file the page resolves. What's up with that?

tim
  • 2,530
  • 3
  • 26
  • 45
  • Possible dupe http://stackoverflow.com/questions/3144401/htaccess-mod-rewrite-conflicting-with-subfolder-auth – tim Jun 26 '14 at 01:07

2 Answers2

1

The problem derives from the ErrorDocument setting. Adding the following line to admin/.htaccess solves the problem

ErrorDocument 401 "Access Denied"

tim
  • 2,530
  • 3
  • 26
  • 45
0

See my Tips for debugging .htaccess rewrite rules. Unless oyu've overridden the defaults with on of the RewriteOptions Inherit* directives, then because the /admin/.htaccess exists then the parent one won't be executed. Either add

RewriteOptions Inherit

to this file or simply repeat the rewrites that you need in the admin access file.

Community
  • 1
  • 1
TerryE
  • 10,724
  • 5
  • 26
  • 48
  • But the admin folder do not necessarily need any rewriting as it is a physical destination. What seems to be the case is the parent one is the one that is parsed. Isn't it odd how one Virtualhost works and the other does not? – tim Jun 25 '14 at 23:17
  • You can get all sorts of weird effects if you have multiviews enabled by default. Try replicating the -d, -f -l escape in your admin .htaccess – TerryE Jun 27 '14 at 23:46