ianitm Posted October 1, 2008 Share Posted October 1, 2008 Hi, I am running a social networking site that allows a usersname to be entered after the website url for quick access to their profile. I need to have a htaccess file on the root of the server to exlcude certain subdirectories from being percieved as a username - like forums etc. I would like to set up another exculded directory called ebooks (mysite.com/ebooks) which will be password protected. At the moment I have a htaccess file in this subdirectory which is atempting to password protect the folder but I believe the root htaccess is causing an authorization error before the user is even asked for a password. My root htaccess looks like this: RewriteEngine On ErrorDocument 403 /index.php?do=/public/error/403/ ErrorDocument 404 /index.php?do=/public/error/404/ RewriteCond %{REQUEST_URI} !^/file/.* RewriteCond %{REQUEST_URI} !^/install/.* RewriteCond %{REQUEST_URI} !^/.smileys/.* RewriteCond %{REQUEST_URI} !^/cgi-bin/.* RewriteCond %{REQUEST_URI} !^/favicon.ico$ RewriteCond %{REQUEST_URI} !^/forums/.* RewriteCond %{REQUEST_URI} !^/ebook/.* RewriteCond %{REQUEST_URI} !^/index.php$ RewriteCond %{REQUEST_URI} !^/robots.txt$ RewriteCond %{REQUEST_URI} !^/sitemap.xml$ RewriteCond %{REQUEST_URI} !^/design/.* RewriteCond %{REQUEST_URI} !^/plugins/.* RewriteRule ^index.php(/.*)$ /index.php?do=$1 [L] RewriteCond %{REQUEST_URI} !^/design/.* RewriteCond %{REQUEST_URI} !^/plugins/.* RewriteCond %{REQUEST_URI} !^/file/.* RewriteCond %{REQUEST_URI} !^/install/.* RewriteCond %{REQUEST_URI} !^/cgi-bin/.* RewriteCond %{REQUEST_URI} !^/favicon.ico$ RewriteCond %{REQUEST_URI} !^/forums/.* RewriteCond %{REQUEST_URI} !^/ebook/.* RewriteCond %{REQUEST_URI} !^/index.php$ RewriteCond %{REQUEST_URI} !^/robots.txt$ RewriteCond %{REQUEST_URI} !^/sitemap.xml$ RewriteRule ^(.*)$ /index.php?do=/$1 [L] and the htaccess in the ebooks subdirectory, like this: AuthUserFile /home/***/public_html/ebook/.htpasswd AuthGroupFile /dev/null AuthName "Private Area" AuthType Basic <Limit GET POST> require valid-user </Limit> Could anybody please explain why this is giving me a 401 when navigating to the ebooks folder and not requesting the username and password? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/126619-password-protect-sub-directory-htaccess/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.