Deprecated: Function create_function() is deprecated in /www/wwwroot/www.woniu.wang/usr/plugins/AntiSpam/Plugin.php on line 75
Wordpress固定链接怎么设置伪静态 - 蜗牛工作室_刘永个人博客

Wordpress固定链接怎么设置伪静态

发布于 / 知识文档 / 0条评论 / Tags: none / 14 次浏览

  Wordpress固定链接怎么设置伪静态

  wordpress页面的默认链接形式采用”朴素”方式 (例如: http://域名/?p=123)

  这样的动态URL链接不便于搜索引擎的收录,为此,我们需设置为其他几种常见的固定链接形式, 如 http://www.sufaith.com 选择的是 【 自定义结构 】.

  设置方式如下:

  进入wordpress后台系统首页, 点击菜单 【设置】- 【固定链接】

  1971138ece31eaf989ea3a054af72ed.png

  选择【常用设置】 下的 【自定义结构】 , 可选择单个标签或多个标签组合, 可自定义拼接字符串, 本站点使用的是 /%post_id%.html, 填写完毕后, 点击 【保存更改】即可生效.

  aec6ae8adf73ef5b2e70fb065d8086b.png

  保存更改后, 虽然文章或页面的链接变成了固定链接, 但是在访问页面时, 却变成了下载操作, 不能正常访问该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;
    }
}

    评论区(暂无评论)