Windows Azure:将网站从www重定向到非www
发布时间:2020-12-13 22:34:44 所属栏目:Windows 来源:网络整理
导读:我的服务器上有这个web.config文件. rewrite rules rule name="HTTP to HTTPS redirect" stopProcessing="true" match url="(.*)" / conditions add input="{HTTPS}" pattern="off" ignoreCase="true" / /conditions action type="Redirect" redirectType="F
我的服务器上有这个web.config文件.
<rewrite> <rules> <rule name="HTTP to HTTPS redirect" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> </conditions> <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" /> </rule> <rule name="Rule" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> <add input="{URL}" pattern="^/favicon.ico$" ignoreCase="false" negate="true" /> </conditions> <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" /> </rule> </rules> </rewrite> 我想将URL从www重定向到非www.例如,如果用户键入www.exmaple.com,则应转至https://example.com 如何在上面的代码中编辑这样的东西.谢谢. 解决方法
你可以用这种方式(我在一个规则中合并https / non-www规则)
<rule name="HTTPS and non-WWW only" stopProcessing="true"> <match url="^(.*)$" /> <conditions logicalGrouping="MatchAny"> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> <add input="{HTTP_HOST}" pattern="^www." ignoreCase="true" /> </conditions> <action type="Redirect" redirectType="Found" url="https://example.com/{R:1}" /> </rule> <rule name="Generic default rule" stopProcessing="true"> <match url="^(.*)$" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <add input="{REQUEST_URI}" pattern="^/favicon.ico$" ignoreCase="true" negate="true" /> </conditions> <action type="Rewrite" url="/index.php/{R:1}" appendQueryString="true" /> </rule> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- Windows – LDAP上的DC的第三方通配符证书
- 从Windows Azure上的.NET应用程序连接到VPN?
- windows-server-2008 – IIS 7.5 FTPS外部访问 –
- windows – 使用NET USE以只读方式安装网络驱动器
- 在锁定或解锁Windows XP时运行脚本
- Filezilla客户端无法从Filezilla Server获取目录
- windows-7 – 通过SSH到Windows 7的远程桌面框
- windows-phone-7 – RestSharp – WP7 – 无法将
- windows – 从Get-WinEvent获取用户名
- XAML水平Stackpanel滚动
热点阅读