有以下NGINX配置:
server {
listen 80;
listen [::]:80;
server_name <name>;
client_max_body_size 32m;
root /home/ulnda/www/wordpress;
index index.html index.php;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
include fastcgi_params;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME /home/ulnda/www/wordpress$fastcgi_script_name;
fastcgi_param PHP_VALUE post_max_size=20M;
fastcgi_param PHP_VALUE upload_max_filesize=20M;
}
}
Run Code Online (Sandbox Code Playgroud)
网站在域名上正常运行,例如http://somedomain.com.但是当我尝试用固定链接http://somedomain.com/post-about-sea打开一些帖子时,我收到404错误.我该如何解决?谢谢!
那一个应该工作.Nginx不应该在您的配置中返回404.
server {
listen 80;
listen [::]:80;
server_name <name>;
client_max_body_size 32m;
root /home/ulnda/www/wordpress;
index index.html index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
include fastcgi_params;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME /home/ulnda/www/wordpress$fastcgi_script_name;
fastcgi_param PHP_VALUE post_max_size=20M;
fastcgi_param PHP_VALUE upload_max_filesize=20M;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3232 次 |
| 最近记录: |