Forum Moderators: phranque

Message Too Old, No Replies

Mod rewrite & HTTP Authentication - Help!

How do I resolve this conflict?

         

ungrounded

4:53 pm on Aug 23, 2009 (gmt 0)

10+ Year Member



Hi All,

I am very nearly pulling my hair out over this. I have a site with a subdirectory for admins only, which I want to block using digest authentication. I also want just about every URL to be re-written using mod_rewrite. I can get everything working just fine independently, but if I try to get both working together, I only get 404 errors on the admin page. Here are my apache rules. Currently, they are in an htaccess file for testing, but I plan to move them to the httpd.conf once I figure out the correct directives.

In the /admin subdirectory. Users browse here by entering www.url.com/admin

/admin/.htaccess


AuthType Digest
AuthName "Admin"
AuthUserFile /security/digest
Require user admin

In the web root, the mod_rewrite is enabled.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

If I comment out either one, the whole page works correctly. When both are on, I get only 404 Not Found on anything in the /admin directory, but every other directory works great. What am I missing to make them both work together?

Thanks so much!

jdMorgan

6:18 pm on Aug 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Add a rewritecond to the root .htaccess, so that the WP rewrite doesn't kick in for /admin requests.

RewriteCond %{REQUEST_URI} !^/admin/

For a minor efficiency benefit, make this the first rewritecond in the 'stack' of three.

Jim