.htaccess: Password protect your entire site except certain pages


/ Published in: Apache
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.