I can get these two features to work independently but cant seem to combine them.
Can anyone point me in the right direction?
- Code: Select all
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
# If no-www domain requested, externally redirect to www domain
RewriteCond %{HTTP_HOST} ^sample\.com
RewriteRule (.*) http://www.sample.com/$1 [R=301,L]
#
# If www+subdomain or subdomain+www domain requested, externally redirect to subdomain without "www"
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.sample\.com [OR]
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.sample\.com
RewriteRule (.*) http://%1.sample.com/$1 [R=301,L]
#
#
# BELOW IS WHERE IM RUNNING INTO TROUBLE
#
# Takes subdomain and adds it to the end of the url as $_GET['acct']
RewriteCond %{HTTP_HOST} !^www\.sample\.com
RewriteCond %{HTTP_HOST} !^blog\.sample\.com
RewriteCond %{HTTP_HOST} ([^.]+)\.sample\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?acct=%1 [L]
#
#
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule (.*) index.php?page=$1 [QSA,L]