Use domain as "prefix" on CakePHP
Let's say that I have a site running CakePHP and I have the prefix "product".
I have lots of pages with URL like:
http://mysite.com/produt/blue-shirt/details
http://mysite.com/produt/blue-shirt/order
http://mysite.com/produt/skate/details
http://mysite.com/produt/sun-glasses/vendors
Now I need to use a domain like http://mysite-blue-shirt.com/
as "shortcut" to the blue-shirt product, and my URLs will become:
http://mysite-blue-shirt.com/details
http://mysite-blue-shirt.com/order
What I need to do?
I think that's something with the .htaccess
on the root of the website, outside the 开发者_开发问答app
directory.
Here's the current syntax:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
Try this:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysite-blue-shirt\.com
RewriteCond %{REQUEST_URI} !^/product/blue-shirt
RewriteRule ^(.*)$ app/webroot/product/blue-shirt/$1 [L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
The first line checks the site's name. The second one checks if it has already not been re-written to blue-shirt. The final line carries out the rewrite.
I think you'll need to create your own custom Routing class. Check this: http://mark-story.com/posts/view/using-custom-route-classes-in-cakephp
For the outside world to see this you would need to register mysite-blue-shirt and all the other variants.
精彩评论