玖叶教程网

前端编程开发入门

wordpress伪静态规则(Apache Nginx IIS)

整理了wordpress三种不同web环境下的伪静态规则,方便日后取用

(一)Apache伪静态规则.htaccess

Aapache伪静态规则通常是以.htaccess形式存放于网站根目录,复制伪静态代码在目录里新建.htaccess即可

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

(二)Nginx伪静态规则

Nginx伪静态需要添加伪静态到网站配置文件的server代码段之内

if (!-e $request_filename){
	rewrite ^.+?(/wp-.*) $1 last;
	rewrite ^.+?(/.*\.php)$ $1 last;
	rewrite ^ /index.php last;
}

(三)IIS伪静态规则web.config

web.config为IIS7.5以上的版本所支持的伪静态格式,iis6现已淘汰所以就不再支持。把伪静态规则整体复制新建web.config到网站根目录即可

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="WordPress" stopProcessing="true">
<match url="^(.*)#34; />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

发表评论:

控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言