I would like to be able to assign dynamic subdomains to every company that signs up on my website. I know this question has been asked many times on Stackoverflow (e.g. Dynamic creation of subdomains), but those solutions are not working for me. I might have something else going wrong somewhere, hence I created a new thread.
I would like to be able to have URLs like this:
http://mycompany.testing.com/office
My site is in a subdirectory like this:
htdocs/office
I have my urlManager
setup like this:
'urlManager' => array(
'urlFormat' => 'path',
'showScriptName' => false,
'rules' => array(
'http://<company:\w+>.testing.com/office' => 'office',
'/<action:\w+>' => '/index/<action>',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
),
)
My apache virtual host entry looks like this:
<VirtualHost *.testing.com>
...
DocumentRoot "C:/xampp/htdocs/office"
ServerName www.testing.com
ServerAlias *.testing.com
<Directory "C:/xampp/htdocs/office">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I added 127.0.0.1 *.testing.com
in my Windows hosts
file. And my htaccess file looks like this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
I have tried following the Yii guide (which shows this as a very simple task), but I think I might have messed up something outside the application itself.
Any input will be highly appreciated :-)
Have a good day.