Nginx location domain.ltd正则表达式 [英] Nginx location domain.ltd regex

查看:101
本文介绍了Nginx location domain.ltd正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要重写域whois,例如http://domainname.ltd/example.com必须被调用http://domainname.ltd/whois.php?d=example.com

i need rewrite for domain whois for example http://domainname.ltd/example.com must be call http://domainname.ltd/whois.php?d=example.com

我尝试位置示例,但不起作用.

i try location examples but not working.

推荐答案

您可以这样做:

server {
  listen 80;
  server_name test.com;

  location = /whois.php {
    proxy_pass http://your_origin_host.com
  }

  location ~ \/(.*) {
    set $domain_query $1;
    set $args "d=${domain_query}";
    rewrite ^ /whois.php last;
  }
}

这篇关于Nginx location domain.ltd正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆