【发布时间】:2016-01-18 05:31:59
【问题描述】:
我正在使用 nginx 将子域添加到我的主域。问题是我的其他服务器索引的代理是 myip/folder/index.php 我在我的添加主机文件中制定了重写规则,当我尝试访问 subdomain.mydomain.com 时,它会重定向到 myip/folder/index.php,但索引的完整路径是可见的。如何在我的添加主机文件中隐藏路径? 我的添加主机文件如下所示:
server {
listen 80;
server_name subdomain.mydomain.com;
location / {
proxy_pass http://192.168.0.0/;
rewrite ^/$ http://subdomain.mydomain.com/folder/index.php# permanent;
}
}
【问题讨论】:
-
看来您的
location参数/是主要问题。您想用匹配所有的通配符替换斜杠。您使用的语法旨在发送默认文件,如 index.php。 -
我尝试按文件夹更改
/参数,但我仍然可以看到完整路径。