Textpattern logo

Help?

Password Protecting a Section Using .htaccess

From Textbook

Describes how to easily establish HTTP authentication to protect a Section of your Texpattern site. Assumes your Web site is run on an Apache Web server, and that you have that you already have an existing .htpasswd file containing usernames and passwords.

Typical scenario:

Your website is at domain.tld, Textpattern is installed in the root directory, and you want to password protect the section called protected (domain.tld/protected)

The Process

  1. Physically create a folder as suggested by the Txp section (in our example it would be protected).
  2. Within the protected directory, create an .htaccess file and add the following to it:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*) ../index.php
</IfModule>

AuthType Basic
AuthUserFile /path/on/server/to/.htpasswd
AuthName "Only for registered users"
require valid-user

Notes

If you need to initially create your .htpasswd and .htaccess files, one way is to check and see if your host’s control panel offers an automated way of doing it. For example, TextDrive provides this ability.

Translations [?]...

About Textbook