【发布时间】:2019-07-29 22:30:41
【问题描述】:
所以我有一个 nginx 服务器,我有一堆 wordpress 网站 像这样
/var/www/html/siteone
/var/www/html/sitetwo
当我使用浏览器转到http://localserver/siteone 时,它可以工作,但是当我转到子文件夹或子页面时,例如http://localserver/siteone/about,它总是404。
我知道您应该设置多个位置块,但我不想这样做!我希望能够将文件夹添加到根目录,放入 wordpress 文件,一切正常。有什么建议吗?
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
#try_files $uri $uri/ =404;
index index.php index.html index.htm;
#try_files $uri $uri/ /index.php?$args;
try_files $uri $uri/ /index.php$is_args$args;
fancyindex on;
fancyindex_localtime on;
fancyindex_exact_size off;
fancyindex_header "/Nginx-Fancyindex-Theme-light/header.html";
fancyindex_footer "/Nginx-Fancyindex-Theme-light/footer.html";
fancyindex_ignore "Nginx-Fancyindex-Theme-light";
fancyindex_ignore "phpmyadmin";
}
location ~ \.php$ {
client_max_body_size 1024M;
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_intercept_errors on;
# With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}
location ~ /\.ht {
deny all;
}
}
【问题讨论】: