We have recently implemented sub domains as part of our site. So to access each of our clients pages on our site, you would go to http://client.oursite.com.
I also got a few other rules to force www, if there is no sub domain, and any of the sub domain pages are handled by one script.
The rules that I used to get that working are as follows
- Code: Select all
# Forcing no sub domain to WWW. eg: site.com -> www.site.com
RewriteCond %{HTTP_HOST} ^([-a-z0-9_]+\.[-a-z0-9_]+)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
# Rules for checking for a sub domain
RewriteCond %{HTTP_HOST} !^www\.[-a-z0-9_]+\.[-a-z0-9_]+$ [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.[-a-z0-9_]+\.[-a-z0-9_]+$ [NC]
RewriteRule ^$ /sub_domain_pages/sub_domain_page.php?listing=%1 [QSA,L]
# Rule for writing non listing pages sub domain back to WWW
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^www\.[-a-z0-9_]+\.[-a-z0-9_]+$ [NC]
RewriteCond %{HTTP_HOST} ^.+\.([-a-z0-9_]+\.[-a-z0-9_]+)$ [NC]
RewriteRule !^sub_domain_pages/sub_domain_page\.php$ http://www.%1%{REQUEST_URI} [R=301,L]
All works well and good there, but if I try something like this http://client.oursite.com/description, I get a 404 error ;(
To give a little background, each of the clients we load on have a few different sections they need to display. So I created some tab, you click on the tab, and bam you go there, but I got to make it a nice pretty URL
Does anyone know what im doing wrong?
Can anyone help?
Thanks in advance