在nginx下修改wordpress固定链接地址,使用官方的默认固定链接,可能会降低搜索引擎爬取速度,为此修改对引擎爬虫友好的固定链接,有利于提高站点的访问量
1、修改固定链接
登入wordpress后台,修改如下:
刷新界面后却出现下面的错误:
2、404错误解决方法
这是因为nginx配置出了问题,我们需要修改在nginx的配置文件,如果wordpress在根目录,则在location / {} 大括号里添加下列代码
location / {
if (!-e $request_filename) {
rewrite (.*) /index.php;
}
index index.php index.html index.htm;
}
如果是子目录,则在location /xxx {} 大括号里添加下列代码
location /xxx {
if (!-e $request_filename) {
rewrite (.*) /xxx/index.php;
}
index /xxx/index.php /xxx/index.html /xxx/index.htm;
}
完整的nginx配置如下:
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 80;
server_name domain_name;
rewrite ^ https://server_namerequest_uri permanent;
}
server {
listen 443;
server_name domain_name ;
root /usr/share/nginx/html;
error_log /var/log/nginx/uedbox.com.log crit;
ssl on;
ssl_certificate /etc/nginx/conf.d/xxx.crt;
ssl_certificate_key /etc/nginx/conf.d/xxx.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # do not use SSLv3 ref: POODLE
client_max_body_size 20M;
location / {
if (!-e $request_filename) {
rewrite (.*) /index.php;
}
index index.php index.html index.htm;
}
}
}
0