我使用 NAT 在虚拟机中运行 nginx,当我从主机访问它时出现了重定向问题。
http://localhost/test/
。这是我想要的 强根据我在谷歌上搜索的内容,我尝试了 server_name_in_redirect off;
和 rewrite ^([^.]*[^/])$ $1/ permanent;
,但都没有成功。
server {
listen 80;
server_name localhost;
# server_name_in_redirect off;
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
location ~ \.php$ {
# rewrite ^([^.]*[^/])$ $1/ permanent;
root /usr/share/nginx/html;
try_files $uri =404;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}