last day (14 days later) » 

7:31 AM
0
A: How to protect a specific url through htaccess

anubhavaYou can use it this way with mod_setenvif: SetEnvIfNoCase Request_URI ^/testing SECURED AuthName "Restricted Area" AuthType Basic AuthUserFile /path/to/your/.htpasswd AuthGroupFile / Require valid-user Satisfy any Order Allow,Deny Allow from all Deny from env=SECURED

 
not working ..even the testing page is opening without any password protection. No prompt appearing. Have a look at my htaccess code
 
Same exact code works on my Apache. It is asking for authentication only for /testing URI otherwise it doesn't show auth dialog at all
 
what should be /path/to/your/.htpasswd htapsswd is located in root
 
It should have full filesystem path of password file.
 
server error is appearing now when i changed the path while echoing $_SERVER["DOCUMENT_ROOT"];
 
7:31 AM
Password file should not be writable by group/others but you must check your Apache error.log to know why you're getting that error.
 
AuthUserFile takes one argument, text file containing user IDs and passwords This error is appearing in error logs
 
I have mine as AuthUserFile /Users/anubhava/htdocs/htpasswd there shouldn't be any space other than between AuthUserFile and full path
 
is this wrong? AuthUserFile D:/DONT DELETE 80-261209/ABCProjects/xampp/htdocs/abc_shareware/.htpasswd
 
Yes it is wrong. Use it as: AuthUserFile "D:/DONT DELETE 80-261209/ABCProjects/xampp/htdocs/abc_shareware/.htpasswd"
 
means path in double qoutes ?
 
7:31 AM
yes............
 
Not working No errors. Please have a look at my question under Updated Code. I have pasted the htaccess code..
 
What is exact URL you're using to test this?
 
there ?
 
yes
 
& i want to restrict this url only this
this is my htaccess code
SetEnvIfNoCase Request_URI ^/testing-softwares SECURED

AuthName "Restricted Area"
AuthType Basic
AuthUserFile "D:/DONT DELETE 80-261209/NRLProjects/xampp/htdocs/nrl_shareware/.htpasswd"
AuthGroupFile /
Require valid-user

Satisfy any
Order Allow,Deny
Allow from all
Deny from env=SECURED


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /nrl_shareware/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
 
7:32 AM
then change this line SetEnvIfNoCase Request_URI ^/testing-softwares SECURED to this: SetEnvIfNoCase Request_URI /testing-softwares SECURED
i.e. remove ^ from pattern
 
done its working
thanks dear
 
great
 
can we share cell number ? I wont bother you for sure
 
it is easier to contact me via twitter/email since I work in night hours and turn my phone to airplane mode to avoid disturbing others
anubhavas@gmail.com is my email id
and @anubahva is twitter id
also you can now mark the answer as accepted :)
 

last day (14 days later) »