Apache && Nginx wordpress伪静态(简)

0x01.Apache

在网站的根目录下创建.htaccess,配置如下(要在主配置文件中允许分布式配置):

1
2
3
4
5
6
7
8
<IfModule mod\_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - \[L\]
RewriteCond %{REQUEST\_FILENAME} !-f
RewriteCond %{REQUEST\_FILENAME} !-d
RewriteRule . /index.php \[L\]
</IfModule>

0x02.Nginx

将以下配置加入网站配置文件(一般是nginx.conf)的server容器:

1
2
3
4
5
6
7
8
9
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;
}