JAVA和Nginx 教程大全

网站首页 > 精选教程 正文

wordpress伪静态规则(Apache Nginx IIS)

wys521 2024-09-12 23:17:37 精选教程 36 ℃ 0 评论

整理了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>

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表