发现问题: 近日,发现自建的wordpress网站http跳转https有问题,比如 http://vgo.cc 跳转为:https://www.vgo.cc http://www.vgo.cc 跳转为:https://www.vgo.cc https://vgo.cc 跳转为:https://www.vgo.cc 以上都是正常的,但是以下的http内容页: 输入:http://vgo.cc/718.html 无法变为 https://www.vgo.cc/718.html 输入:http://www.vgo.cc/718.html 无法变为 https://www.vgo.cc/718.html 而是直接跳转到首页:https://www.vgo.cc 实现目标: http://www.vgo.cc/718.html 跳转:https://www.vgo.cc/718.html http://vgo.cc/718.html 跳转:https://www.vgo.cc/718.html https://vgo.cc/718.html 跳转:https://www.vgo.cc/718.html 解决方案: 可参考以下规则我自用的伪静态规则: (记住:先备份好你的原来的web.config文件, 如果这个方法不适合你那么把备份的web.config替换回去即可 , 再把web.config文件复制到本地用Sublime或者Dreamweaver编辑, 把下面的伪静态规则全部替换掉web.config原来内容, 里面的域名"https://www.vgo.cc"替换成你自己的. ) <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <defaultDocument> <files> <add value="index.php"/> </files> </defaultDocument> <rewrite> <rules> <clear /> <rule name="Redirect to https" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" /> </rule> <rule name="WordPress: https://www.vgo.cc" 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> 通过以上的伪静态替换, 使内容页、栏目页和标签页实现http-https轻松301跳转。 本站系统 Windows Server 2012 R2 Web服务器 Microsoft-IIS/8.5 PHP版本 7.3.3 (支持64位数值) mysql 8.0.15 wordpress版本 5.2.2
发表回复