It works for me, but I have my webroot set to app/webroot/ so if you don't I'm not positive if it will work or not.
Put this block right before the existing CakePHP rewrite rules in your app/webroot/.htaccess file
<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} =img.corsilezioni.com
RewriteCond %{PATH_INFO} !^/img/.*
RewriteRule ^(.*)$ index.php/img/$1 [QSA,L]
</IfModule>
You'll need a block just like that for every subdomain you want to support.
All it does is redirect anything after the subdomain (as long as it doens't already start with /img/) to the ImgController.
The first RewriteCond makes the rule only active if we are on the right subdomain
The second RewriteCond makes the rule only active if we don't already have /img/ in the path
The RewriteRule mimics the default CakePHP rewrite rule, but changes the path sent to index.php to include /img/
For example:
http://img.corsilezioni.com/some_action should return the same page as:
http://corselezioni.com/img/some_action
For example, here are the relevant lines from my app/webroot/.htaccess file that I was using for testing purposes:
<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} =test2.mydomain.com
RewriteCond %{PATH_INFO} !^/tests/.*
RewriteRule ^(.*)$ index.php/tests/$1 [QSA,L]
</IfModule>
# Direct all URLs that don't actually exist to CakePHP
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>
The first block is the new rules I added, the second are my default CakePHP rewrite rules. With the above, I was able to visit:
http://test2.mydomain.com/
and I was served the page from http://test2.mydomain.com/tests/ (the index page of the tests controller).
Will something like that work for you?
Thanks,
Ben
-- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment