【发布时间】:2015-03-31 12:55:49
【问题描述】:
我目前正在更新一个网站,并且不得不为一些我们不再使用的旧页面添加一些 301 重定向。我的代码是;
RewriteEngine On
RewriteBase /
Redirect 301 /old-folder/old-file.html http://www.newsite.com/new-folder/
不幸的是,重定向似乎忽略了 html 文件部分,所以当我访问旧链接时,我将被重定向到
http://www.newsite.com/new-folder/old-file.html
第一个孩子之后的任何内容都会被忽略,并且当我尝试使用此代码重定向更复杂的 url 时;
Redirect 301 /old-parent-folder/old-child-folder/old-page.html http://www.newsite.com/new-folder/new-page.html
然后我被重定向到一个损坏的网址,例如;
http://www.newsite.comold-child-folder/old-page.html
这也不是错字,.com 之后的斜线完全被忽略了。
我希望你能在这里看到问题,htaccess 似乎只看旧结构的第一部分而忽略其余部分,导致各种问题和奇怪的链接。
【问题讨论】:
标签: .htaccess mod-rewrite redirect