Skeleton .htaccess file for Powweb Hosting

Powweb Web Hosting One thing that can come in reallly handy if you are in charge of mutliple websites, often adding new ones is a template .htaccess file. Especially for a webhost like Powweb, which is perfect for ordinary people who want a web site. Normally I would recommend DreamHost, but maybe more on that later.

A .htaccess Template For Powweb

Pretty short and to the point, mostly useful for newcomers to apache to have a system whereby they know where stuff should go and how it goes together. This is how I like to do it on Powweb.

Download .htaccess file

  1. Powweb .htaccess
  2. htaccess-sample
#> http://www.askapache.com/htaccess/

##############################################
#            DEFAULT SETTINGS                #
##############################################
Options +All +ExecCGI -Indexes
DirectoryIndex index.html index.php /index.php

### MEDIA TYPES ###
AddType video/x-flv .flv
AddType application/x-shockwave-flash .swf
AddType application/octet-stream .chm .bz2
AddType application/vnd.ms-excel .csv
AddType application/x-pilot .prc .pdb
AddType application/x-gzip .gz
AddType image/x-icon .ico

### CHARSET LANG ###
DefaultType text/html
AddDefaultCharset utf-8
AddLanguage en-us .html .htm .php .xml

### SETUP ENV ###
SetEnv TZ America/Indianapolis
SetEnv SERVER_ADMIN webmaster@site.com
ServerSignature off

### ERRORDOCUMENTS ###
ErrorDocument 206 /ERROR/206.html
ErrorDocument 401 /ERROR/401.html
ErrorDocument 403 /ERROR/403.html
ErrorDocument 404 /ERROR/404.html
ErrorDocument 500 /ERROR/500.html

##############################################
#           HEADERS and CACHING              #
##############################################
#### CACHING ####
ExpiresActive On
ExpiresDefault A3600

# 1 MONTH
<FilesMatch "\.(ico|gif|jpe?g|png|flv|pdf|swf|mov|mp3|wmv|ppt)$">
ExpiresDefault A2419200
Header append Cache-Control "public"
</FilesMatch>

# 2 HOURS
<FilesMatch "\.(xml|txt|html|js|css)$">
ExpiresDefault A7200
Header append Cache-Control "private, must-revalidate"
</FilesMatch>

# NEVER CACHE
<FilesMatch "\.(php|cgi|pl|htm)$">
ExpiresDefault A0
Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
Header set Pragma "no-cache"
</FilesMatch>

##############################################
#          MOD_ALIAS REDIRECTS               #
##############################################
#### PERMANENT REDIRECTS ####
Redirect 301 /all.html http://www.askapache.com/htaccess/
Redirect 301 /awkl http://www.askapache.com/awk/awk-tutorial/
Redirect 301 /ben.html http://www.askapache.com/wordpress/best-adsense-optimization/
Redirect 301 /commonly-s.html http://www.askapache.com/htaccess/commonly-used-htaccess-code-examples/
Redirect 301 /css-backgro http://www.askapache.com/css/css-background-image-sprite/
Redirect 301 /htacce http://www.askapache.com/htaccess/feedsmith-htaccess/

### PERMANENT REDIRECTMATCH ###
RedirectMatch 301 ^/([(]+)(.*)$ http://www.askapache.com/
RedirectMatch 301 ^/(.+).htm$ http://www.askapache.com/$1.html
RedirectMatch 301 ^/(.+).html/$ http://www.askapache.com/$1.html
RedirectMatch 301 ^/(.+)/.html$ http://www.askapache.com/$1/
RedirectMatch 301 ^/&amp(.*)$ http://www.askapache.com/

#### TEMPORARY REDIRECTS ####
Redirect 307 /about/feeds/ http://feeds.askapache.com/apache/htaccess
Redirect 307 /about/feeds/it/ http://feeds.askapache.com/apache/htaccess
Redirect 307 /apachesearch/ http://google.com/coop/cse?cx=002660089121042511758%3Akk7rwc2gx0i
Redirect 307 /apachecsetest/ http://google.com/coop/cse?cx=002660089121042511758%3Akk7rwc2gx0i

#### TEMPORARY REDIRECTMATCH ####
RedirectMatch 307 ^/(.*)//(.*)$ http://www.askapache.com/$1/$2
RedirectMatch 307 ^//(.*)$ http://www.askapache.com/$1
RedirectMatch 307 ^/(.*)askapache(.*)askapache(.*)$ http://www.askapache.com/

##############################################
#          MOD_REWRITE REWRITES              #
##############################################
RewriteEngine On
RewriteBase /

### REQUIRE WWW ###
RewriteCond %{HTTP_HOST} !^www\.site\.com$ [NC]
RewriteRule ^(.*)$ http://www.site.com/$1 [R=301,L]

### CACHEABLE FILES
RewriteRule ^z/j/site-([0-9]+)\.js$ /z/j/site.js [L]
RewriteRule ^z/c/site-([0-9]+)\.css$ /z/c/site.css [L]

##############################################
#          MOD_SETENVIF VARIABLES            #
##############################################
SetEnvIfNoCase Remote_Host "(.*)" ASKAPACHE_HOST=$1
SetEnvIfNoCase Remote_Addr "(.*)" ASKAPACHE_REMOTE_ADDR=$1
SetEnvIfNoCase Server_Addr "(.*)" ASKAPACHE_SERVER_ADDR=$1
SetEnvIf Request_Method "(.*)" ASKAPACHE_REQUEST_METHOD=$1
SetEnvIf Request_Protocol "(.*)" ASKAPACHE_REQUEST_PROTOCOL=$1
SetEnvIf Request_URI "(.*)" ASKAPACHE_REQUEST_URI=$1
SetEnvIf Remote_Addr 208.113.183.103 REMOTE_HOST=www.askapache.com

#> http://www.askapache.com/htaccess/
#            DEFAULT SETTINGS                #
##############################################
Options +All +ExecCGI -Indexes
DirectoryIndex index.html index.php
SetEnv TZ America/Indianapolis
#SetEnv SERVER_ADMIN webmaster@askapache.com
ServerSignature Off
#
AddType video/x-flv .flv
AddType application/x-shockwave-flash .swf
AddType image/x-icon .ico
#
#AddHandler php-cgi .php
#Action php-cgi /cgi-bin/php5.cgi
#
<FilesMatch "\.(html|htm)$">
AddDefaultCharset utf-8
DefaultLanguage en-us
</FilesMatch>

AuthName "Blog"
Require user admin
AuthUserFile /web/users/web/b646/pow.askapache/.htpasswd
AuthType basic

#                  CACHING                   #
##############################################
#   YEAR
<FilesMatch "\.(ico|gif|jpg|jpeg|png|flv)$">
Header set Cache-Control "max-age=29030400"
</FilesMatch>
#   MONTH
<FilesMatch "\.(js|css|pdf|txt|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
#   HOUR
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=3600"
</FilesMatch>

Htaccess Htaccess Powweb skeleton

Comments