Forum Moderators: phranque
Options -Indexes
Options +FollowSymLinks
RewriteEngine On
# Remove www
RewriteCond %{HTTP_HOST} ^www.(.*) [NC]
RewriteRule (.*) http://%1/$1 [R=301,L]
# Redirect foo.com to /foo subdirectory
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^foo.com$ [NC]
RewriteRule .* /foo%{REQUEST_URI} [QSA,L]
# Redirect bar.com to /bar subdirectory
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^bar.com$ [NC]
RewriteRule .* /bar%{REQUEST_URI} [QSA,L]
DirectorySlash off
#
Options -Indexes +FollowSymLinks -MultiViews
#
RewriteEngine on
#
# Externally redirect to remove "www" and any trailing FQDN label or port number
RewriteCond %{HTTP_HOST} ^(www\.)+([^.]+(\.[^.]+)*)\.?(:[0-9]+)?$ [NC]
RewriteRule ^(.*)$ http://%2/$1 [R=301,L]
#
# Internally rewrite specified subdomains to corresponding subdomain-subdirectory
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(foo|bar)\.example\.com
RewriteRule ^(.*)$ /%1/$1 [L]
RewriteCond $1 !^(foo|bar)/