如何在 CakePHP 中启用 SEO 友好的 URL?
我想做一些像 www.mydomain.com/page-slug
指向 www.mydomain.com/custom-pages/view/page-slug
的事情,比如 WordPress 。我怎样才能在 CakePHP 中做到这一点?
I want to do something like www.mydomain.com/page-slug
point to www.mydomain.com/custom-pages/view/page-slug
, something like Wordpress. How can I do this in CakePHP.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将 app/config/routes.php 中的路由器修改
为
这有一个很大的问题。如果您的应用程序除了页面控制器之外还有任何其他控制器,则必须在页面控制器路由之前显式声明其他控制器的路由,如下所示。
所以你的路由器应该看起来像这样
这是我的方法,用于需要来自根/的 seo 友好 url 的网站
you need to modify the Router in app/config/routes.php
to
There is a big gotcha to this. If your application has any other controllers besides the pages controller which it will, you will have to explicitly declare the routes to the other controllers before the pages controller route like this.
so your router should look something like this
This was my approach for a site that reqiured seo friendly urls from the root /