我有一个wordpress网站,其永久链接设置为发布名称 . 除索引外,所有页面都不会出现并返回404 . 如果我把它设置为普通,那么它们会出现,但很多资源都缺失了,我不知道为什么 .
所以要明确一点,如果永久链接很简单,它可以工作,但是由于多个文件上有404(索引除外),因此存在许多错误 . 如果永久链接是postname,那么整个页面是404 .
这是我的htaccess文件,我的nginx配置,以及我的php-fpm配置 . 有谁能看到这个问题?
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
NGINX CONF
server {
listen 80;
server_name www.example.com example.com;
root /var/www/example;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name www.example.com example.com;
root /var/www/example;
index index.php;
ssl_certificate /etc/nginx/ssl/example.com/example.com.crt;
ssl_certificate_key /etc/nginx/ssl/example.com/example.com.key;
access_log /var/log/nginx/example.log main;
error_log /var/log/nginx/example_error.log;
location / {
root /var/www/example;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
PHP-FPM
[example]
listen = 127.0.0.1:9001
listen.allowed_clients = 127.0.0.1
user = nginx
group = nginx
...and some more I don't think is relevant but I can supply if asked for.
谢谢你的帮助!
1 回答
没有看到实际的错误或哪些文件是404 'ing, I think you may be missing try_files in your nginx config. I' d看看这个:http://nginxlibrary.com/wordpress-permalinks/
此外,nginx不需要或不想.htaccess:https://www.nginx.com/resources/wiki/start/topics/examples/likeapache-htaccess/
另外,我会检查以确保您的数据库中的URL设置正确 . (我发布链接,但我没有代表)我会使用wp-cli进行搜索替换 . 我不止一次忘记这样做,从开发到舞台,并有一个wtf时刻 . :)
希望这一切都有帮助!
*** Edited to help a bit more ***
在深入研究这些教程之后,他们遗漏了一些更好的观点 . 没有深入研究,尝试使用更接近这个的东西:
这是您拥有的和我运行的配置的混合 . 让我知道它是如何为你做的 .