.htaccess

From Hostek.com Wiki
Revision as of 00:23, 23 January 2015 by Coryme (Talk | contribs)

Jump to: navigation, search

Can I use a .htaccess file to password protect a directory?

Yes, on our LINUX servers you can use a .htaccess file to password protect a directory.

The code to perform this is:

AuthUserFile /usr/local/you/safedir/.htpasswd
AuthGroupFile /dev/null
AuthName EnterPassword
AuthType Basic

require user wsabstract

Change the File directory to the directory listed in your File Manager.

Enabling Case Insensitive URLs for my Linux site

Add the following to your .htaccess file:

CheckSpelling on

Rewriting all URL requests to WWW.

Add the following to your .htaccess code:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

Rewriting HTTP requests to HTTPS

Add the following to your .htaccess code:

RewriteEngine On
RewriteCond %{HTTPS} !^on$
RewriteRule (.*) https://yourdomain/$1 [R,L]

Create a Wildcard Subdomain Redirect

Add the following to your .htaccess code:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mydomain\.dk$ [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.mydomain.dk$ [NC]
RewriteRule ^(.*)$ http://mydomain.dk/ [P,L,QSA]