Welcome Guest, Not a member yet? Register   Sign In
.htacess password protection folder
#1

[eluser]searain[/eluser]
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|captcha|css|js|php|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

This is my root .htaccess, so I tell that the folder php is not using the Rewrite for clean url, for files in the folder named as "php", it is just using regular url as it is.

Such as

http://www.mysite.com/php/test.php

It is working fine.

But then I also want to put the folder "php" under password protection

So I added the following .htaccess in folder "php"
Code:
require valid-user
Authname "Administration"
Authtype Basic
AuthUserFile /public_html/php/.htpasswd

Afer I did that, I didn't get password protection on the folder "php", insead, I got page not found error when I try to access

http://www.mysite.com/php/test.php

It seems the .htaccess in root and .htaccess in php get conflicts.

Any advice to fix it?

Thanks!
#2

[eluser]theprodigy[/eluser]
try

Code:
AuthUserFile /home/pathto/.htpasswd
AuthType Basic
AuthName "Secret Place"

<LIMIT GET POST>
require valid-user
</LIMIT>

Not sure if it will work, but that is what is shown at this site
#3

[eluser]searain[/eluser]
http://ellislab.com/forums/viewthread/142001/#698395

This gives the answer.

All I need to do is add one more line in root .htaccess

RewriteCond $1 !^(401.shtml)

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|captcha|css|js|php|robots\.txt)
RewriteCond $1 !^(401.shtml)
RewriteRule ^(.*)$ /index.php/$1 [L]

Then I can put .php under .htaccess protection.




Theme © iAndrew 2016 - Forum software by © MyBB