【发布时间】:2013-07-02 11:00:45
【问题描述】:
这是我在 .htaccess 文件中的规则:
Redirect 301 /George-Nelson-Bench-CT3005-EDI6.htm?categoryId=-1 http://www.mydomain.com/proddetail.php?prod=George_Nelson_Bench
但这在我的网站上显示 404 错误。
.htaccess 文件中的一些其他代码是:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]
其他一些正常工作的 301 重定向:
Redirect 301 /Modern-Classics_c8.htm http://www.mydomain.com/categories.php?cat=10
Redirect 301 /Sofas_c34.htm http://www.mydomain.com/products.php?cat=25
Redirect 301 /Bedroom_c2.htm http://www.mydomain.com/categories.php?cat=7
那么,为什么第一个 301 重定向规则不起作用?
有什么建议吗?
【问题讨论】:
-
httpd.apache.org/docs/2.2/en/mod/mod_alias.html#redirect:
Syntax: Redirect [status] URL-path URL...这里的重要部分:URL path -
@CBroe 是的。 URL-path 在规则中是正确的。没有?
-
查询字符串不是 URL路径的一部分。
-
谢谢@CBroe。查询字符串是问题所在。