Answer the question
In order to leave comments, you need to log in
How to solve the problem with dynamic subdomains?
The situation is this, the site has a bunch of dynamic subdomains, like username.site.com, they are all processed by one yii application using mod_rewrite:
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.site\.com$ [NC]
RewriteRule (.*) index.php?un=%2 [NC,QSA]
Answer the question
In order to leave comments, you need to log in
A couple of years ago, a similar question was asked on the Russian-language yii forum. I described the solution to a similar problem in this topic .
Briefly
apache virtualhost settings:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "D:/Projects/WWW/urlShortener"
ServerName urlshortener.localdomain
ServerAlias *.urlshortener.localdomain
ErrorLog "logs/urlShortener.localdomain-error.log"
CustomLog "logs/urlShortener.localdomain-access.log" common
<Directory />
DirectoryIndex index.php
</Directory>
</VirtualHost>
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
array(
'http://<user:\w+>.example.com/<lang:\w+>/profile' => 'user/profile',
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question