【发布时间】:2017-01-31 22:59:52
【问题描述】:
我有一个 WordPress 博客托管在一个名为 /blog 的子目录中,我正在尝试使用 %postname% 字符串获得漂亮的永久链接,但它所做的只是返回一个 404 错误。
我尝试了多种解决方案来尝试解决此问题,但都没有奏效。我错过了什么还是有更好的方法来解决这个问题?在这一点上,我唯一能想到的是权限问题,但这不太可能。
我的 NGINX 配置文件如下:
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/allamericangold.com/html/blog;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name allamericangold.com www.allamericangold.com 104.198.9.91;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php$args;
}
location /blog/ {
try_files $uri $uri/ /blog/index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php7.0-cgi alone:
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
【问题讨论】: