本文已同步到专业技术网站 www.sufaith.com, 该网站专一于先后端开发技术与经验分享, 包含Web开发、Nodejs、Python、Linux、IT资讯等板块.php
wordpress页面的默认连接形式采用”朴素”方式 (例如: http://域名/?p=123)html
这样的动态URL连接不便于搜索引擎的收录, 为此, 咱们需设置为其余几种常见的固定连接形式, 本网站 http://www.sufaith.com 选择的是 【 自定义结构 】.nginx
设置方式以下:后端
进入wordpress后台系统首页, 点击菜单 【设置】- 【固定连接】wordpress
选择【经常使用设置】 下的 【自定义结构】 , 可选择单个标签或多个标签组合, 可自定义拼接字符串, 本站点使用的是 /%post_id%.html, 填写完毕后, 点击 【保存更改】便可生效.post
保存更改后, 虽然文章或页面的连接变成了固定连接, 可是在访问页面时, 却变成了下载操做, 不能正常访问该URL地址, 这时须要配置nginx的伪静态(URL Rewrite)规则.网站
如下为nginx的配置, 需修改成你本身的域名和root路径.搜索引擎
server { listen 80; server_name www.example.com; root /usr/local/www/wordpress; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$args; } rewrite /wp-admin$ $scheme://$host$uri/ permanent; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
修改完配置后, 重启nginx便可生效, 恢复正常访问.spa
systemctl restart nginx.service