【发布时间】:2017-02-09 05:54:53
【问题描述】:
在domain.com 上托管了一个博客,其永久链接设置为domain.com/article and domain.com/category。
现在,博客移到domain.com/blog,其他一些内容直接放在domain.com上:file2.php,filex.php
现在,当用户输入domain.com/articlex 以重定向到domain.com/blog/articlex 时,如何进行重定向?
为了不干扰新内容,我正在考虑将 404 页面响应重定向 301。
我正在使用 ErrorDocument 404 404.php 在 .htaccess 中尝试,并从那里进行 301 重定向,但没有可用的 $_SERVER[REQUEST_URI]。
另外,RewriteCond %{ENV:REDIRECT_STATUS} = 404 使用查询字符串重定向我没有成功。
【问题讨论】:
-
我设法使它与默认的 404.shtml 一起工作,并且重定向是使用 location,window 进行的。
标签: php .htaccess redirect http-status-code-404