webroot 中的 CakePHP 文件夹被重定向到 app/webroot/folder
在 CakePHP 中,您可以通过 domain/file 访问 webroot 中的文件,
例如位于 app/webroot/favicon.ico 的 favicon.ico 文件可以可以从访问
example.com/favicon.ico
另一方面,目录似乎有一个问题。
如果我在 app/webroot/ 中有一个名为 blog 的目录,那么只要我尝试像这样访问它:
example.com/blog/
然后它按预期工作。但是,如果我尝试在没有尾部斜杠的情况下访问它:
example.com/blog
然后它被重定向到:
example.com/app/webroot/blog/
这是不受欢迎的。我宁愿将 .com/folder
重定向到 .com/folder/
而不是 .com/app/webroot/folder/
如何设置这个?
In CakePHP you can access files in webroot via domain/file
For example the favicon.ico file located at app/webroot/favicon.ico can be accessed from
example.com/favicon.ico
Directories on the other hand seem to have a gotcha.
If I have a directory called blog in the app/webroot/, then as long as I try to access it like:
example.com/blog/
Then it works as expected. However if I try to access it without the trailing slash:
example.com/blog
Then it gets redirected to:
example.com/app/webroot/blog/
This is undesired. I woult rather .com/folder
get redirected to .com/folder/
instead of .com/app/webroot/folder/
Is there a way to set this up?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您在文档根目录中安装了 wordpress blog 和 cakephp,则需要将 .htaccess 文件脚本替换为以下脚本:
If you installed wordpress blog and cakephp in document root, you need to replace .htaccess file script with below script:
使用 Router::Connect for blog 直接重定向到好页面怎么样?当然,这不是一个自动例行程序,但它可能会对您有所帮助。
更多信息: http://book.cakephp.org/view/945/Routes-Configuration< /a>
我想配置核心文件中可能有一个参数,你已经看过了吗?
What about using the Router::Connect for blog to redirect directly to the good page? Of course this is not an automatic routine but it mighthelp you.
More info : http://book.cakephp.org/view/945/Routes-Configuration
I suppose there might be a parameter in the config core files, have you already had a look there?
您可以尝试此处的说明
You could try the instructions here