推荐方法:
1、web.config文件中,删除wordpress生成的伪静态地址
2、根目录的web.config 设置为只读
方法一
1、主配置文件恢复为初始web.config;
<?xml version="1.0" ?>
<configuration>
<location allowOverride="false" inheritInChildApplications="false" path=".">
<system.webServer>
<rewrite>
<rules configSource="web_config\rewrite.config"></rules>
</rewrite>
<defaultDocument configSource="web_config\default.config"></defaultDocument>
<httpErrors configSource="web_config\httpErrors.config"></httpErrors>
<handlers configSource="web_config\php.config"></handlers>
</system.webServer>
</location>
</configuration>
2、登录后台设置伪静态;
3、把生成的伪静态拷贝到伪静态配置那边;
4、锁定配置文件(可以面板网站目录栏目锁定,或则服务器参考下图锁定);
参考:https://www.bt.cn/bbs/thread-33097-1-1.html
方法二
更新完伪静态,网站和后台报错500,那是因为<rewrite> </rewrite>
重复了导致的
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location allowOverride="false" inheritInChildApplications="false" path=".">
<system.webServer>
<rewrite>
<rules configSource="web_config\rewrite.config"/>
</rewrite>
<defaultDocument configSource="web_config\default.config"/>
<httpErrors configSource="web_config\httpErrors.config"/>
<handlers configSource="web_config\php.config"/>
</system.webServer>
</location>
<system.webServer>
<rewrite>
<rules>
<rule name="WordPress: http://180.76.242.203" patternSyntax="Wildcard">
<match url="*"/>
<conditions>
<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>
解决方法:删除下面的命令,伪静态直接走web.config
<rewrite>
<rules configSource="web_config\rewrite.config"/>
</rewrite>