我需要为html文件名中包含空格的URL创建重定向.
我需要与此相当的nginx:
Redirect 301 "/Poorly Titled File.html" http://domain.com/new-url/
我试过了:
rewrite ^/Old\%20Page\%20Title.html$$scheme://domain.com/new-url/ permanent;
location /Old\%20Page\%20Title.html{
return 301 $scheme://domain.com/new-url/;
}
有和没有逃避%的.
最佳答案
使用’在该位置附近:
location '/Old Page Title.html' {
return 301 $scheme://domain.com/new-url/;
}
另见SO Nginx rewrite that includes a blank spce问题.