我正在开发一个网站,其中有一些非常糟糕的网址可以重定向,例如: -
/sites/default/files/files/National%20Commission%20of%20Enquiry%20-%20Intensive%20Alternative%20to%20Custody%20in%20Greater%20Manchester.doc
执行此操作(删除ASCII空格)会导致500错误: -
redirect 301 /sites/default/files/files/National Commission of Enquiry - Intensive Alternative to Custody in Greater Manchester.doc http://www.makejusticework.org.uk/wp-content/uploads/National-Commission-of-Enquiry-Intensive-Alternative-to-Custody-in-Greater-Manchester-1.pdf
将空格保留为%20只是404。我假设它的ASCII字符正在阻碍 - 是否有一种可靠的方法来重定向这样的URL?
答案 0 :(得分:1)
尝试用字符本身替换%-encoded字符。因为你有一些空格,你需要把网址放在引号之间(“/sites/.../space here”)
所以在你的情况下:
redirect 301 "/sites/default/files/files/National Commission of Enquiry - Intensive Alternative to Custody in Greater Manchester.doc" http://www.makejusticework.org.uk/wp-content/uploads/National-Commission-of-Enquiry-Intensive-Alternative-to-Custody-in-Greater-Manchester-1.pdf