I managed to get some subdomains working, but the outcome aint perfect yet. 'www', 'forum', 'img' and 'my' all work perfectly as subdomains.
Here is my code:
- Code: Select all
Options +indexes
Options +FollowSymLinks
RewriteEngine On
#loop stopping code.
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]
#display news /news/id/
RewriteRule ^news/([0-9]+)/$ /news/viewnews.php?id=$1 [NC,L]
#display an error /error/errortag/
RewriteRule ^error/([a-z]+)/$ /errors/displayError.php?error=$1 [NC,L]
#logout by visiting this link /logout/
RewriteRule ^logout/$ /logout.php [NC,L]
#forward to root
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ /$1 [QSA,L]
#forward to root
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ /$1 [QSA,L]
#forward to forums
RewriteCond %{HTTP_HOST} ^forum\.example\.com$ [NC]
RewriteRule ^(.*)$ /forum/$1 [QSA,L]
#forward to images
RewriteCond %{HTTP_HOST} ^img\.example\.com$ [NC]
RewriteRule ^(.*)$ /images/$1 [QSA,L]
#forward to account
RewriteCond %{HTTP_HOST} ^my\.example\.com$ [NC]
RewriteRule ^(.*)$ /account/$1 [QSA,L]
#forward to users
RewriteCond %{HTTP_HOST} ^(.*)\.example\.com$ [NC]
RewriteRule ^users/($1)/ [L]
#404 error handling
ErrorDocument 404 /errors/index.php
Could anyone help me make this work?
For some reason the 404 errorhandling doens't work either.