htaccess redirect to public folder caught in authentication

htaccess redirect to public folder caught in authentication - .htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, , , , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :


I have an .htaccess file at the root of my server which has auth on it. I have a redirect statement that upon entering example.myserver.com instead of myserver.com redirects the user to a sub folder with Satisfy any in the .htaccess, BUT when using example.myserver.com the auth seems to kick in before the redirect happens, is there a way to let it see that the folder to redirect to is public?



Options -MultiViews +FollowSymLinks
RewriteEngine On
RewriteCond %HTTP_HOST ^example.server.com$
RewriteRule ^(/)?$ subfolder [L]



AuthUserFile /var/.htpasswd
#AuthGroupFile /dev/null
AuthName Welcome
AuthType Basic

require user someone

IndexOptions +ShowForbidden
ErrorDocument 401 /error401.html
ErrorDocument 404 /errorGeneric.html
ErrorDocument 500 /errorGeneric.html


and the .htaccess of the subfolder just has Satisfy any in it


Solution :

It is not wise to require authentication on your home page aka site root unless you do not want your site seen at all. You have to give people a place to land. Generally, a portion of any site would not require authentication. This gives you and your potential user the opportunity to know about your site, offerings, products, prices, access to contact and about, etc. Then the protected content would be in a sub-folder or a sub-domain.



Having placed authentication on your root takes priority over other processing. When you think of Apache there is a request process priority order. Authentication is a high priority function that I am sure trumps processing any .htaccess file.


Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.

Comments

Popular posts from this blog

Rewrite in Mediawiki, remove index.php, .htaccess

.htaccess rewrite wildcard folder paths from host

Using .htaccess to set a cookie and 301 redirect