Posted By

abbey on 02/23/10


Tagged

regex htaccess filesmatch


Versions (?)

.htaccess: Password protect your entire site except certain pages


 / Published in: Apache
 

URL: http://www.webmasterworld.com/apache/4051548.htm

Before taking a site "live", I password protect it except the robots.txt for search engines and custom Error pages. You can adapt this to your own use and add other pages in the FilesMatch directive.

  1. # These pages are public
  2. <FilesMatch "^(robots\.txt|errorpage\.php)$">
  3. order allow,deny
  4. allow from all
  5. </FilesMatch>
  6.  
  7. # The rest of the site is private
  8. AuthUserFile /path/to/your/.htpasswd
  9. AuthType Basic
  10. AuthName "Login Required"
  11. Require valid-user
  12. Order allow,deny
  13. Satisfy any

Report this snippet  

You need to login to post a comment.