howtos » apache
CODE:
-
#Activate the rewrite engine if it isn't so already
-
RewriteEngine on
-
#intercept all HTTP requests to the site that do not have a 'www.' at the beginning of the Domain name
-
#and then force a redirect to the same page address only this time, including the 'www.'
-
RewriteCond %{HTTP_HOST} !^www\..* [NC]
-
RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R=301]
-
#The inverse of the above rule - intercept HTTP requests with a 'www.' at the start and redirect to the non-www version
-
# Ensure that your serverName directive is set up to the non-www name of your domain
-
RewriteCond %{HTTP_HOST} ^www\..* [NC]
-
RewriteRule ^(.*) http://%{SERVER_NAME}/$1 [R=301]
htpasswd is a command line tool for creating and updating user authentication files. These files are primarily used by apache to authenticate HTTP users.
Creating a password file
CODE:
-
htpasswd -c /path/to/.htpasswd username
Adding a user & password
CODE:
-
htpasswd -b /path/to/.htpasswd username password