Nginx location domain.ltd regex

谁说我不能喝 提交于 2019-12-11 16:47:33

问题


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.


回答1:


you can do it like this:

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


来源:https://stackoverflow.com/questions/58029307/nginx-location-domain-ltd-regex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!