Apache modrewrite examples
modrewrite rule if you create folder it can be used as a subdomain
RewriteCond %{HTTP_HOST} !^www\.website\.com$
RewriteCond %{HTTP_HOST} ^(.*)\.website\.com(.*) [NC]
RewriteCond %{DOCUMENT_ROOT}/%1 -d
RewriteRule ^(.*)$ http://www.website.com/%1$1 [P,L]
requires both mod_rewrite and mod_proxy to be running
1. Forcing www for a domain while preserving subdomains
RewriteCond %{HTTP_HOST} ^([a-z.]+)?example\.com$ [NC] RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule .? http://www.%1example.com%{REQUEST_URI} [R=301,L]
Site has permanently moved to new domain
# domain.com to domain2.com
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain2.com/$1 [R=301,L]
RewriteEngine on
RewriteCond /your/docroot/%{REQUEST_FILENAME} !-f
RewriteRule ^(.+) http://webserverB.dom/$1