I have another question. I am using the code posted above with a few modifications to the directory structure, as follows:
- Code: Select all
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.((.)(.).+)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^((.)(.).+)$ [NC]
RewriteCond %{DOCUMENT_ROOT}/domains/%2/%3/%1%{REQUEST_URI}/public_html/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^www\.((.)(.).+)$ [NC,OR]
RewriteCond %{HTTP_HOST} ^((.)(.).+)$ [NC]
RewriteRule ^(.*)$ /domains/%2/%3/%1/public_html/$1 [QSA,L]
Now what I'd like to do is split out the sub-domain, if any.
If the domain is mydomain.com or
www.mydomain.com then use this directory: /domains/m/y/mydomain.com/public_html/
If there is a sub-domain other then www, such as test.mydomain.com then use this directory: /domains/m/y/mydomain.com/sub_domains/test/
Any help much appreciated!