如何使用 .htaccess 从以前的 CakePHP 页面重定向到非 CakePHP 页面
我从我们之前使用 CakePHP 的网站进行了一些重定向。新网站有纯 PHP 页面。当尝试在 .htaccess 文件中重定向以下内容时,我遇到了问题:
Redirect 301 /old-page-here http://samesitename.com/somedirectory/newfilename.php
/old-page-here 的扩展名为 .ctp。当我在浏览器中运行它时,我得到一个循环,其中 newfilename.php 一遍又一遍地出现(以及其他网址信息 - 但不重复)。
当 CakePHP 放入页码时,我遇到了类似的问题,例如
Redirect 301 /olddirectory/old-page-here/2 http://samesitename.com/somedirectory/newfilename-2.php
,当它将两个目录添加到网址中时。重定向位于 webroot 目录(从数据库中提取)内且不以斜杠数字结尾的页面已定向为 OK。
有什么想法出了什么问题吗?
I have some redirects in place from our previous site that used CakePHP. The new site has plain PHP pages. When trying to redirect the following in an .htaccess file I am having problems:
Redirect 301 /old-page-here http://samesitename.com/somedirectory/newfilename.php
The /old-page-here had the extension .ctp. When I run this in my browser I get a loop with newfilename.php appearing over and over again (as well as the other webaddress information - but not repeated).
I was having a similiarish problem with when CakePHP put page numbers in, e.g.
Redirect 301 /olddirectory/old-page-here/2 http://samesitename.com/somedirectory/newfilename-2.php
When it would add both directories into the webaddress. Redirecting pages that were within the webroot directory (pulled from the database) that did not end in a slash-number have directed OK.
Any ideas what is going wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许 这 可以在构建时派上用场你的新网址。至于您在仍然安装 cakephp 时遇到的重定向问题:我可以想象,从“外部”实现这有点复杂,因为在流程中的某个地方,cake 的调度程序将地址分解为控制器、操作、参数。从“内部”,你可以做到
使用状态代码重定向。
Maybe this could come in handy for building your new urls. As for your trouble with redirecting when cakephp was still installed: I can imagine that this is somewhat complicated to achieve from "outside", as somewhere in the process cake's dispatcher dissolves the address into controller,action, parameters. From the "inside", you can do
redirects with a status code.