Hi to All forum members.
This is my first post on Yii forum.
I have a website that runs on Yii 1.1 framework. The site is active for 2 years and now I want to support subdomains feature for all the registered users. My htaccess is configured to redirect all traffic to www site i.e if I type domain.com into URL then it gets redirected to www,domain,com and my primary website is rendered. I have changed my DNS settings and added *.domain.com record and added this in routes in URL Manager:
'<username:\w+>,domain,com' => 'public/profile'
which means that if user types URL with subdoman then he is sent to PublicController’s profile action. But now the problem is that all of my traffic even for primary domain is going to this route. i.e
www,domain,com----------------------------->public/profile
As a result of that I am unable to access my primary website. Here is my htaccess code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
# add www if not subdomain
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^ http///www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# remove www if subdomain
RewriteCond %{HTTP_HOST} ^www\.([^.]+\.[^.]+\.[^.]+)$ [NC]
RewriteRule ^ http///%1%{REQUEST_URI} [R=301,L]
How do I support both the things that when user types username,domain,com it routes to only public/profile route and all other traffic (www,domain,com) traffic runs as normal.
I have been searching for solution for 2 days. Would greatly appreciate any help.
Thanks
Note: Since I am new to forum and not allowed to post links so I am replacing dot (.) with comma (,) wherever URL is being used.