使用空格()为URL创建Nginx重定向

前端之家收集整理的这篇文章主要介绍了使用空格()为URL创建Nginx重定向前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我需要为html文件名中包含空格的URL创建重定向.

我需要与此相当的Nginx

  1. Redirect 301 "/Poorly Titled File.html" http://domain.com/new-url/

我试过了:

  1. rewrite ^/Old\%20Page\%20Title.html$$scheme://domain.com/new-url/ permanent;
  2. location /Old\%20Page\%20Title.html{
  3. return 301 $scheme://domain.com/new-url/;
  4. }

有和没有逃避%的.

最佳答案
使用’在该位置附近:

  1. location '/Old Page Title.html' {
  2. return 301 $scheme://domain.com/new-url/;
  3. }

另见SO Nginx rewrite that includes a blank spce问题.

猜你在找的Nginx相关文章