当url中有空格时,htaccess重定向

Mah*_*kia 13 html url .htaccess redirect web

我想从仍然出现在Google搜索中的旧网址重定向到新网址.旧网址是这样的:

http://www.marionettecolla.org/file%20_mostra_milano/mostra_marionette-milano.htm
Run Code Online (Sandbox Code Playgroud)

我想将其重定向到主页:

http://www.marionettecolla.org/
Run Code Online (Sandbox Code Playgroud)

我在我的.htaccess中使用了这个:

Redirect http://marionettecolla.org/file\ _mostra_milano/mostra_marionette-milano.htm http://marionettecolla.org/
Run Code Online (Sandbox Code Playgroud)

但我得到错误500 ...有谁知道如何解决这个问题?

Mah*_*hdi 20

这应该有效:

Redirect 301 "http://marionettecolla.org/file _mostra_milano/mostra_marionette-milano.htm" http://marionettecolla.org/
Run Code Online (Sandbox Code Playgroud)

把它放在一对双引号之间 " ... "

更新:

这是另一种方式,适用于任何类型的空间:

redirectMatch 301 http://marionettecolla.org/file[\s]_mostra_milano/mostra_marionette-milano.htm http://marionettecolla.org/
Run Code Online (Sandbox Code Playgroud)

  • 我已经更新了解决方案......你可以看到`[\ s]`那里.这个也应该有效...... (2认同)

use*_*900 12

你不能像"\"那样逃避空间.正确的方法是"\ s".

虽然我不确定在htaccess文件中用"\ s"代替空格是否可行.如果有效,请告诉我.