nginx将子域重写为文件作为变量
发布时间:2020-10-19 17:31:59 所属栏目:Nginx 来源:互联网
导读:如何将子域作为要在重写中添加的变量?hello.example.com应该转到example.com/user.php?u=hello但仍显示为hello.example.com我目前正在做http://example.com/users/hello,但希望为用户提供Tumblr风格的域名.rewrite ^/users/(.*)$/user.php?u=$
如何将子域作为要在重写中添加的变量? hello.example.com应该转到example.com/user.php?u=hello但仍显示为hello.example.com 我目前正在做http://example.com/users/hello,但希望为用户提供Tumblr风格的域名.
另外,如果子域名为/ settings /之后的页面为hello.example.com/settings/,我需要重写为settings.php 最佳答案 两件事情.首先,您需要读取主机变量以获取子域并将其设置为稍后使用的变量.我使用了变量$sub_domain,然后将变量附加到URI.
重写行需要进一步调整.我在这里举了一个例子.有关可用选项,请参阅内置的nginx variables documentation. (编辑:岳阳站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |