Posted By

abbey on 02/23/10


regex htaccess filesmatch

Versions (?)

.htaccess: Password protect your entire site except certain pages

 / Published in: Apache


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>
  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.