使用域作为“前缀”在 CakePHP 上
假设我有一个运行 CakePHP 的站点,并且有前缀“product”。
我有很多页面的 URL 如下:
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
现在我需要使用像 http://mysite-blue-shirt.com/
这样的域作为 blue-shirt 产品的“快捷方式”,以及我的 URL会变成:
http://mysite-blue-shirt.com/details
http://mysite-blue-shirt.com/order
我需要做什么?
我认为这是网站根目录下 app
目录之外的 .htaccess
的问题。
这是当前的语法:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个:
第一行检查站点的名称。第二个检查它是否尚未被重写为 blue-shirt。最后一行执行重写。
Try this:
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.
我认为您需要创建自己的自定义路由类。检查这个: http://mark-story.com/帖子/视图/使用自定义路由类-in-cakephp
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
为了让外界看到这一点,您需要注册 mysite-blue-shirt 和所有其他变体。
For the outside world to see this you would need to register mysite-blue-shirt and all the other variants.