我有一个超过100个redirect的列表,几乎所有这些似乎都在工作,除了两个。 我正在使用htaccess 301redirect的通用格式:
redirect 301 /shop/category.cfm/wall-decals http://wallcandyarts.com/wall-decals.html
据我所知,这一点没有错。 我有问题的是这两个:
redirect 301 /shop/product.cfm/chalkboard-wall-panels http://wallcandyarts.com/chalkboard-decals/chalkboard-panels.html redirect 301 /shop/category.cfm/chalkboard-decals http://wallcandyarts.com/chalkboard-decals.html
我已经阅读了有关查询string的问题,但这不是这种情况。 我还看到,在组装这个redirect列表时,如果新path以“/”结尾,那么会导致它获得与上面的redirect相似的结果。 例如,点击http://www.wallcandyarts.com/shop/product.cfm/chalkboard-wall-panels会给你一个“泥”的URL,我不知道为什么。 有什么想法吗?
这是我第一次进入任何与htaccess相关的东西,不涉及简单的复制/粘贴,所以请原谅我的无知。 希望学到很多。
谢谢!
更新:这是整个htaccess。 在我之前join了301条指令之前,有很多东西。 我添加的代码从181行开始。
http://pastie.org/2371768
其他人为你工作吗? 我尝试了一些,我已经试过/shop每个/shop下我的浏览器下wall-decals.html 。
http://wallcandyarts.com/shop/product.cfm/seasons-designer-pillows成为http://wallcandyarts.com/wall-decals.html/product.cfm/seasons-designer-pillows 。
罪魁祸首是你的最后一行:
redirect 301 /shop http://wallcandyarts.com/wall-decals.html
Redirect指令是基于前缀匹配的。 正如文档所述:
Redirect /service http://foo2.bar.com/service If the client requests http://myserver/service/foo.txt, it will be told to access http://foo2.bar.com/service/foo.txt instead.
抓住所有/shop最后一条规则就是打击每一个针对/shop规则。 我不完全确定如何处理Redirect的评估/优先级,但是RedirectMatch可能更适合您的需求(或者至less应该用于最后一条规则)。
RedirectMatch 301 ^/shop/product\.cfm/frames-wall-decals$ http://wallcandyarts.com/wall-decals/frames-decals.html ... RedirectMatch 301 ^/shop/?$ http://wallcandyarts.com/wall-decals.html
首先,你应该把所有的代码限制在你的httpd.conf文件中,而不是htaccess。 更多的安全威胁,因为人们可以自由下载并使用它对你。 至于失败的redirect…目标网页不存在正如规则中引用的那样?