All pastes #124039 Raw Edit

Untitled

public text v1 · immutable
·published 2006-08-09 20:00 UTC
rendered paste body
RewriteEngine on
RewriteLog /usr/local/apache/logs/rewrite.log
RewriteLogLevel 9
RewriteMap      lc              int:tolower
#if www.example.com end and go to www.example.com
RewriteCond   %{HTTP_HOST}                 ^www\.example\.com$ [NC]
RewriteRule   ^(.+)             - [L]
#if example.com end and go to example.com
RewriteCond   %{HTTP_HOST}                 ^example\.com$ [NC]
RewriteRule   ^(.+)                        - [L]
#if www.foo.example.com 301 to foo.example.com - THIS ONE'S IMPORTANT
#I honestly don't know what the 2nd or 3rd lines of this section do
RewriteCond   %{HTTP_HOST}                 ^www\.[^.]+\.example\.com$ [NC]
RewriteRule   ^(.+)                        %{HTTP_HOST}=$1 [C]
RewriteRule   ^(.*)=(.*)                   ${lc:$1}$2 [C]
RewriteRule ^www\.([^.]+)\.example\.com http://$1.example.com/ [R=301,L]
#these last 3 lines are to rewrite foo.example.com/something to www/example.com/foo/something
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/icons
RewriteRule (.*) /www/example.com/%1$1