howtos » apache

CODE:
  1. #Activate the rewrite engine if it isn't so already
  2. RewriteEngine on
  3. #intercept all HTTP requests to the site that do not have a 'www.' at the beginning of the Domain name
  4. #and then force a redirect to the same page address only this time, including the 'www.'
  5. RewriteCond %{HTTP_HOST} !^www\..* [NC]
  6. RewriteRule ^(.*) http://www.%{HTTP_HOST}/$1 [R=301]
  7. #The inverse of the above rule - intercept HTTP requests with a 'www.' at the start and redirect to the non-www version
  8. # Ensure that your serverName directive is set up to the non-www name of your domain
  9. RewriteCond %{HTTP_HOST} ^www\..* [NC]
  10. 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:
  1. htpasswd -c /path/to/.htpasswd username

Adding a user & password

CODE:
  1. htpasswd -b /path/to/.htpasswd username password