0

我正在一个网站上工作,该网站有一些非常糟糕的网址要重定向,例如:-

/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,比如这个?

4

1 回答 1

1

尝试用字符本身替换 % 编码的字符。因为那里有一些空格,所以需要将网址放在引号之间(“/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
于 2012-04-10T15:01:57.080 回答