伪静态:伪静态是相对真实静态来讲的,通常我们为了增强搜索引擎的友好面,都将文章内容生成静态页面,但是有的朋友为了实时的显示一些信息。或者还想运用动态脚本解决一些问题。不能用静态的方式来展示网站内容。但是这就损失了对搜索引擎的友好面。怎么样在两者之间找个中间方法呢,这就产生了伪静态技术。就是展示出来的是以html一类的静态页面形式,但其实是用ASP一类的动态脚本来处理的。

首先,在Nginx中的server模块配置如下内容:

location / {
  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;
      }
  }

如果使用phpstudy,上面内容直接复制,phpstudy网站管理中伪静态设置中。

 

配置完成后,重启Nginx。

然后,在wordpress博客后台的“设置”——“固定链接”,自定义结构:/%category%/%post_id%.html 即:分类/文章id.html

 wordpress的固定链接形式。网上常见的几种设置方法:
/%year%/%monthnum%/%day%/%postname%/
/%year%/%monthnum%/%postname%/
/%year%/%monthnum%/%day%/%postname%.html
/%year%/%monthnum%/%postname%.html
/%category%/%postname%.html
/%category%/%post_id%
/%postname%.html
/%post_id%.html 

wordpress首次登陆网站,部分链接带localhost。自行修改系统设置。

 

更多推荐

Nginx设置wordpress伪静态