- Code: Select all
RewriteEngine On
RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 9
RewriteMap domain2website txt:/etc/apache2/domain-websitemap.map
#don't rewrite these references, leave them as is
RewriteRule ^/static(/.*)?$ - [NC,L]
RewriteRule ^/thepencilroom/(app|response|contact|cart)(/.*)?$ - [NC,L]
#if the url is blank other than the domain, add "home" to it and continue
RewriteRule ^/$ /home [R,L]
#to allow the system to work without apache (ie, just using tomcat) most urls written will put in "thepencilroom"
#to get to the servlet, but because when using apache "thepencilroom" is automatically added
#if the incoming url contains the text, then remove it
RewriteRule ^/thepencilroom/(.*)$ /$1 [R,L]
#quick access to the admin console via admin.example.com
RewriteCond %{HTTP_HOST} ^admin\.example\.com$ [NC]
RewriteRule .* /thepencilroom/app [QSA,PT,L]
#do the virutal mass hosting
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com$ [NC]
RewriteRule .* /thepencilroom%{REQUEST_URI}/website/%2 [QSA,PT,L]
#do the mapping from a real registered domain to the appropriate example website
RewriteCond %{HTTP_HOST} !^(.*\.)?example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^(.+)$ [NC]
RewriteCond ${domain2website:%1|:} ^([^:]+)$
RewriteRule .* /thepencilroom%{REQUEST_URI}/website/%1 [QSA,PT,L]