Please wait while we load your page...
 

Announcements

HTACCESS Magic :: Page 6







Results 11 to 12 of 16

Password Protect a Single File

Normally, you would password protect a directory, and by adding a .htaccess file to the directory as follows:

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /full/path/to/password/file/.htpasswd
require valid-user


To password protect just a single file (in this example, admin.php), modify as follows:

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /full/path/to/password/file/.htpasswd
<Files "admin.php">
require valid-user
</Files>


One is only prompted to authenticate if they call the admin.php file, but not any other file in the same directory.

Last Revised: 2015-07-17

Redirect HTTP To HTTPS

The following Rewrites will redirect users who access site as HTTP to HTTPS:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]


Note 1: To use Rewrite, (1) site must be hosted on an Apache web server, (2) mod_rewrite module must be compiled into Apache, and (3) mod_rewrite must be enabled for your domain.
Note 2: R=301 is a permanent redirect, and is the most efficient and "Search Engine Friendly" method for redirection. Alternatively, you can use R=302 for temporary redirect if the redirect is not permanent.

Last Revised: 2015-07-05



Live Chat Not Available