【问题标题】:301 redirect will not work with %20 in url301 重定向不适用于 url 中的 %20
【发布时间】:2012-12-19 07:22:01
【问题描述】:

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

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

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

【问题讨论】:

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


    【解决方案1】:

    尝试添加引号。所以

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

    【讨论】:

    • Gerben,感谢您的回答,但这也不起作用。它会导致出现服务器错误页面。也许它与fatcow有关? Acutally 我错过了报价。让我再试一次!对不起!
    • @evangelion3258 你说的胖子是什么意思?
    • 不客气。作为回报,请将其标记为已回答。谢谢。
    • 嗨,我正在尝试让它工作,但这种情况不适用于引号,给出 500 错误(尝试了多种变体)RedirectMatch 301 ^/2012 files/(.*)$ /archives/old-website/2012 files/$1
    • @Yatko 是否加载了 mod_alias 模块?也可以试试RedirectMatch 301 ^/2012\ files/(.*)$ /archives/old-website/2012\ files/$1
    【解决方案2】:

    将页面名称放在引号中就可以了,例如:

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

    【讨论】:

      猜你喜欢
      • 2015-12-30
      • 2017-08-28
      • 1970-01-01
      • 2013-10-31
      • 2020-09-06
      • 2010-12-08
      • 1970-01-01
      • 2014-08-21
      • 1970-01-01
      相关资源
      最近更新 更多