Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Url rewriting nginx子域重写_Url Rewriting_Nginx - Fatal编程技术网

Url rewriting nginx子域重写

Url rewriting nginx子域重写,url-rewriting,nginx,Url Rewriting,Nginx,另一个nginx重写规则问题: 如何从http://www.*.domain.com至http://*.domain.com if ($host ~* www\.(.*)) { set $host_without_www $1; rewrite ^(.*)$ http://$host_without_www$1 permanent; # $1 contains '/foo', not 'www.mydomain.com/foo' } 服务器故障的答案: 类似问题:请注意,这会产生一个双

另一个nginx重写规则问题:

如何从
http://www.*.domain.com
http://*.domain.com

if ($host ~* www\.(.*)) {
  set $host_without_www $1;
  rewrite ^(.*)$ http://$host_without_www$1 permanent; # $1 contains '/foo', not 'www.mydomain.com/foo'
}
服务器故障的答案:

类似问题:请注意,这会产生一个双查询字符串,对
/?foo=bar
的请求将重定向到
/?foo=bar?foo=bar
。使用
$uri
似乎可以达到预期效果,但可能有更好的选择。是否添加?$request\u uri之后将避免重复的查询字符串问题。服务器名称后面缺少分号。现在不推荐使用这种方法。请参阅。建议的方法是什么?
server {
  listen 80;
  listen 443;
  server_name ~^www\.(\w+)\.domain\.com$;
  location / {
    rewrite ^ $scheme://$1.domain.com$request_uri? permanent;
  }
}