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'
}

来自服务器故障的回答:
https://serverfault.com/questions/139579/nginx-subdomain-rewrite

关于url-rewriting - nginx 子域重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2785538/

相关文章:

ajax - 使用 Nginx Lua POST 请求表单数据操作

ubuntu - stream_get_contents():SSL 操作失败,代码为 1。OpenSSL 错误消息:错误:0A000126:SSL 例程::读取时出现意外 eof

.htaccess - 如何在 Ubuntu、nGinx 和 codeigniter 中启用 URL 重写?

php - docker compose 环境变量未在 Dockerfile 中设置变量

css - url 重写不访问我的 css 和图像?为什么

php - 如何重写 URL,使用户看起来好像在他们不在的地方?

html - 基本标签的替代品

nginx - 如何编写用于替换查询字符串中的查询参数的 nginx 重写规则

asp.net-mvc - 如何确保 POST 上的小写 URL?

asp.net - 在 web.config 中使用 ExecuteURL 作为 404 处理程序将绕过 URL 重写(即.. outboundRules),而使用其他 responseModes 则不会