Apache Reference

Yep.. You guessed it, some frequently utilized things that I wanted to have at easy grasp instead of digging.

htaccess primer

The comments above the following commands let you know exactly what these will do. Figure its self explanatory at that point.

# change the index file
DirectoryIndex home.html

# remove directory listing for a folder
Options All -Indexes

# Use PHP4 as default
AddHandler application/x-httpd-php4 .php

# use PHP5 as default
AddHandler application/x-httpd-php5 .php

# redirect domain into a subfolder
RewriteEngine on
RewriteCond %{HTTP_HOST}    ^(ww+\.)?domain\.com
RewriteCond %{REQUEST_URI} !/domain/
RewriteRule ^(.*)$ /domain/$1 [L]

run cron securely allowing only the hosts you wish to have execute the script, add in the additional hosts to allow.

<Files "cron.php"> 
  Order deny,allow 
  Allow from 127.0.0.1 
  Deny from all
</Files>

Need to have fun with some additional domains getting added to a site? This would be the htaccess rule to start from, just extend the first 3 lines for each additional domain, assuming you want the final domain to be found with the ever popular CNAME www. prefixed.

RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^/?$ "http\:\/\/www\.newdomain\.com\/" [R=301,L]

RewriteCond %{HTTP_HOST} !^www\.newdomain\.com$ [NC]
RewriteRule .* http://www.newdomain.com/ [L,R=301]