wordpress配置伪静态

未配置伪静态的worpdress

image.png

浏览器端配置

浏览器中设置的内容:/archives/%post_id%.html

image.png

 

nginx中配置

   vim /application/nginx/conf/extra/blog.conf

server {
    listen       80;
    server_name  blog.abc.com;
    location / {
        root   html/blog;
        index  index.php index.html index.htm;
        ##### wei jing tai ###
        if (-f $request_filename/index.html) {
          rewrite (.*) $1/index.html break;
        }
        if (-f $request_filename/index.php) {
          rewrite (.*) $1/index.php;
        }
        if (!-f $request_filename) {
          rewrite (.*) /index.php;
        }
    }
 
    #php jie xi
    location ~ .*\.(php|php5)?$ {
        root html/blog;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
    }
}


重载nginx

   /application/nginx/sbin/nginx -t

   /application/nginx/sbin/nginx -s reload

mv /application/nginx/html/blog/index.html{,.bak}


浏览器访问检查

image.png


配置方法二

浏览器端配置

image.png

nginx中配置

   vim /application/nginx/conf/extra/blog.conf

server {
    listen       80;
    server_name  blog.abc.com;
    location / {
        root   html/blog;
        index  index.php index.html index.htm;
        ##### wei jing tai ###
        rewrite ^/([0-9]+)/([0-9]+)/([0-9]+)/([0-9]+)\.html$ /index.php?p=$4 last;
       # if (-f $request_filename/index.html) {
       #   rewrite (.*) $1/index.html break;
       # }
       # if (-f $request_filename/index.php) {
       #   rewrite (.*) $1/index.php;
       # }
       # if (!-f $request_filename) {
       #   rewrite (.*) /index.php;
       # }
    }
        #php jie xi
    location ~ .*\.(php|php5)?$ {
        root html/blog;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi.conf;
    }
}



 

重载nginx

   /application/nginx/sbin/nginx -t

   /application/nginx/sbin/nginx -s reload

浏览器访问检查

image.png