我有一个基于Nginx的VPS,上面有WordPress博客。它是一个Centos 7。
我遇到自定义永久链接的问题。
我当前的网站.conf
看起来像这样
server {
listen 80;
server_name example.com www.example.com;
# note that these lines are originally from the "location /" block
root /var/www/example.com/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# Directives to send expires headers and turn off 404 error logging.
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|
ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}
# Uncomment one of the lines below for the appropriate caching plugin (if used).
#include global/wordpress-wp-super-cache.conf;
#include global/wordpress-w3-total-cache.conf;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我可以使用永久链接结构:
www.example.com/%post-name%
我想用它像:
www.example.com/download-%post-name%-online
当我保存自定义固定链接结构并打开任何帖子时,永久链接工作正常,即显示 www.example.com/download-whatsapp-online 在地址栏中,但实际显示的内容是主页。
如果有人能纠正我的.conf
错误,那将会很高兴。
谢谢。欢呼声。