Answer by Thomas Leu for Password protect a specific URL
In Apache2.4 you can do:<If "%{REQUEST_URI} =~ m#/pretty/url/?#i"> AuthUserFile /var/www/htpasswd AuthName "Password protected" AuthType Basic Require valid-user</If>
View ArticleAnswer by Mohammad for Password protect a specific URL
First of all, you need to create a new user/password:This command:htpasswd -c /etc/apache2/.htpasswd myuser1If you are using Bitnami Apps (Open edx, for example), you need follow this...
View ArticleAnswer by Pierre Priot for Password protect a specific URL
I updated Jon Lin's code for the purpose of protecting all URLs except for one - for instance robots.txt at the vhost's root. These are Apache 2.2 compliant directives.<ifmodule...
View ArticleAnswer by Imanuel for Password protect a specific URL
Since Rick stated in a comment that no answer in this question works, here is the snippet I use:AuthName "Protected Area"AuthType BasicAuthUserFile /path/to/your/.htpasswdAuthGroupFile...
View ArticleAnswer by mgutt for Password protect a specific URL
What about redirecting the user to a password protected subfolder? .htaccessRewriteCond %{HTTP_COOKIE} !BadHorsie=secret_cookie_keyRewriteRule ^(pretty/url)$ /protected/login.php?url=$1...
View ArticleAnswer by Stefan for Password protect a specific URL
All the provided solutions didn't work for me. I figured following directives do the trick:SetEnvIf Request_URI ^/page-url auth=1AuthName "Please login"AuthType BasicAuthUserFile...
View ArticleAnswer by simne7 for Password protect a specific URL
Unfortunately I can't comment on @jon-lin answer. So, I create a new answer. My adapted solution in an apache 2.4 environment is:## password protect /pretty/url URIs#AuthType BasicAuthName...
View ArticleAnswer by Coder for Password protect a specific URL
You can use <LocationMatch> or simply <Location> inside your <VirtualHost> directive to do this (assuming you have access to your httpd.conf / vhost.conf - alternatively you could put...
View ArticleAnswer by Dennis for Password protect a specific URL
the solution above is too busy and messed up a bit.. I go for simplicity and clarity like this<Files "protected.html"> AuthName "Username and password required" AuthUserFile...
View ArticleAnswer by Jon Lin for Password protect a specific URL
You should be able to do this using the combination of mod_env and the Satisfy any directive. You can use SetEnvIf to check against the Request_URI, even if it's not a physical path. You can then check...
View ArticlePassword protect a specific URL
The site is on shared hosting. I need to password protect a single URL.http://www.example.com/pretty/urlObviously that's not a physical file path I'm trying to protect, it's just that particular...
View Article