301重定向不适用于url中的%20

时间:2013-01-04 20:09:45

标签: .htaccess http-status-code-301

我正在尝试创建此重定向:

Redirect /commercial%20work.html http://nataliearriolaphotography.com/fine-art-photography-prints.html

问题在于,当我第一次创建此页面时,我在文件名中留下了一个空格。换句话说,它是“/commercial work.html”。在chrome和safari中,url读取如上所示,%20代替空格,但是当我创建此重定向时,它不起作用。我也尝试了以下内容:

Redirect /commercial work.html http://nataliearriolaphotography.com/fine-art-photography-prints.html

这也不起作用。它会导致出现服务器错误页面。有没有人有什么建议?谢谢!

2 个答案:

答案 0 :(得分:23)

尝试添加引号。所以

Redirect "/commercial work.html" http://nataliearriolaphotography.com/fine-art-photography-prints.html

答案 1 :(得分:2)

将页面名称放在引号中应该这样做,例如:

Redirect 301 "/commercial work.html" http://nataliearriolaphotography.com/fine-art-photography-prints.html