wordpress在nginx和apache环境伪静态配置规则

nginx规则:

location / {
	index index.html index.php; 
	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; 
	} 
} 

apache规则:

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

IIS7.5配置web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
                <rule name="category">
                    <match url="category/?(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="/index.php?category_name={R:1}" appendQueryString="false" logRewrittenUrl="false" />
                </rule>
                <rule name="tags">
                    <match url="tag/?(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Rewrite" url="index.php?tag={R:1}" />
                </rule>
                <rule name="Main Rule" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:0}" />
                </rule>
                <rule name="wordpress" patternSyntax="Wildcard">
                    <match url="*" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" />
                </rule></rules>
    </rewrite>
  </system.webServer>
</configuration>

在wordpress后台设置==>固定链接==>自定义结构==>输入/%post_id%.html

【本站资源无偿免费分享,如果资源对你有用,希望动动手指点点下面的广告吧!以维持服务器运行】
如需 WordPress 优化加速、主题修改、故障解决等服务,可联系我购买付费服务: 点此联系我 | 近期站内热门福利:

本文最后更新于5个月前 (05-09),若有错误或已失效,请在下方留言或联系QQ87200080

未经允许禁止转载
本文地址:https://www.77nn.net/337.html
版权声明:本文为原创文章,版权归 讯沃blog 所有,未经允许,禁止任何单位或个人转载!

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝、微信、QQ扫一扫,即可进行扫码打赏哦

0
分享到:

评论6

9 + 7 =
  1. 我记得我来过。
    创意生活5年前 (2015-10-06)  江西省抚州市 回复
     6楼
1 2
没有账号? 忘记密码?

社交账号快速登录