1

I've been searching for a while now and there must be a simple answer for this. I want to apply a password authorization in my htaccess file, but only for the top url of my site. So for example, I'd like for a password prompt to appear if you access the url "mydomain.com", but not to appear for the url "mydomain.com/articles" (and I'm talking specifically about a url, not a server directory location). Is this possible? I know how to password protect the entire site, with the code below:

AuthType Basic
AuthName "restricted area"
AuthUserFile "/home/passwords/.htpasswd-file"
Require valid-user

...which works for me. I'm just not sure how to adjust this so that the password prompt only appears on the very top url of the site.

Edit: To clarify, I'm not talking about subdirectory access, but URL access. The url "mydomain.com/articles" I think is a rewritten URL from Magento, there isn't an "articles" directory on my site.

Edit 2: Also to clarify a bit more, I can't do a FilesMatch on the index.php file of the site, because it seems Magento the index.php is used for serving all of the urls on the site (so if I password protect index.php, the whole site is inaccessible).

Zero Wing
  • 233
  • 2
  • 12
  • possible duplicate of [How to remove .htaccess password protection from a subdirectory](http://stackoverflow.com/questions/1431378/how-to-remove-htaccess-password-protection-from-a-subdirectory) – showdev Mar 27 '15 at 00:39
  • @showdev The link you've posted is the opposite of the question I've asked and doesn't answer my question (if it does, if you could please explain how it answers my question I would appreciate it). – Zero Wing Mar 27 '15 at 00:57
  • Using `.htaccess`, you'll need to exclude each subfolder from the password protection configured at the root. Protecting the root will protect all subfolders as well. – showdev Mar 27 '15 at 01:14
  • No, that's not what my question is about. I can make it so that all subfolders are accessible even while password-protecting the whole site (if I put a directive on the index.php file of the site, the entire site is protected, but the subfolders are still accessible). What I'm looking for is a way to only make it so that the top URL of the site is password protected, and no other url on the site. It's not a question of directory access, but url access. – Zero Wing Mar 27 '15 at 01:37
  • Okay, I'm sorry for misunderstanding. – showdev Mar 27 '15 at 17:02
  • That's okay, thank you for at least taking a look. – Zero Wing Mar 27 '15 at 18:49
  • At the risk of further polluting the comment area, does this help? [Password Protect a Specific URL](http://stackoverflow.com/questions/14603568/password-protect-a-specific-url) – showdev Mar 27 '15 at 18:56

0 Answers0