最近我和我的一个htaccess文件出现了奇怪的问题。 基本上,我不得不将404页面重定向到相关的子页面,我检查了几个随机的页面并且认为一切正常,直到我检查了所有这些并且意识到只有大约60%的规则确实有效。
我无法找到问题的解决方案,我尝试了很少的方法。
以下是我正在使用的重定向301的示例列表:
Redirect 301 /products/sampleproduct http://www.mysite.co.uk/products/overhead-lifting-solutions
**Redirect 301 /products/sampleproduct/rail-system http://www.mysite.co.uk/products/overhead-lifting-solutions/rail-systems
**Redirect 301 /products/sampleproduct/floor-wall-mounted-cranes http://www.mysite.co.uk/products/overhead-lifting-solutions/jib-cranes
**Redirect 301 /products/sampleproduct/vacuum-lifter-easyhand-t http://www.mysite.co.uk/products/overhead-lifting-solutions/vacuum-lifters
Redirect 301 /products/sampleproduct/vacuum-lifter-easyhand-m http://www.mysite.co.uk/products/overhead-lifting-solutions/vacuum-lifters
**Redirect 301 /products/sampleproduct/vacuum-lifter-vacuhand-v http://www.mysite.co.uk/products/overhead-lifting-solutions/vacuum-lifters
**Redirect 301 /products/sampleproduct/end-effectors http://www.mysite.co.uk/products/overhead-lifting-solutions/end-effectors
Redirect 301 /products/sampleproduct/mechline http://www.mysite.co.uk/products/overhead-lifting-solutions/chain-hoists
**Redirect 301 /products/sampleproduct/mechchain http://www.mysite.co.uk/products/overhead-lifting-solutions/chain-hoists
无效的重定向标记为**。我有超过160个重定向,大约有60个不起作用。
答案 0 :(得分:1)
第二个stack.size()
规则无效,因为第一个规则优先。第一条规则是重定向任何以Redirect
开头的内容,从而始终覆盖/products/sampleproduct
。您可以使用正则表达式锚点反转规则的顺序或更好地使用/products/sampleproduct/rail-system
正则表达式支持:
RedirectMatch
您需要对其余规则进行此修复,并确保在测试之前清除浏览器缓存。