将非 www 重定向到 www asp.net web.config
Redirect non-www to www asp.net web.config
我尝试使用 web.config
文件中的代码片段将非 www 转换为 www URL 但我遇到编译错误
<rewrite>
<rules>
<clear />
<rule name="WWW Rewrite" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true"
pattern="^www\.([.a-zA-Z0-9]+)$" />
</conditions>
<action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}"
appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
编译错误:
Unable to start debugging on the web server. See help for common
configuration errors. Running the web page outside of the debugger may
provide further information.
Make sure the server is operating correctly. Verify there are no
syntax errors in web.config by doing a Debug.Start Without Debugging.
You may also want to refer to the ASP.NET and ATL Server debugging
topic in the online documentation.
我该如何解决这个问题?
您需要确保您拥有 URL Rewrite module installed 否则它不会工作,并且您会收到与 IIS 相关的错误,无法理解 web.config 中的 rewrite
部分。
我尝试使用 web.config
文件中的代码片段将非 www 转换为 www URL 但我遇到编译错误
<rewrite>
<rules>
<clear />
<rule name="WWW Rewrite" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true"
pattern="^www\.([.a-zA-Z0-9]+)$" />
</conditions>
<action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}"
appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
编译错误:
Unable to start debugging on the web server. See help for common configuration errors. Running the web page outside of the debugger may provide further information.
Make sure the server is operating correctly. Verify there are no syntax errors in web.config by doing a Debug.Start Without Debugging. You may also want to refer to the ASP.NET and ATL Server debugging topic in the online documentation.
我该如何解决这个问题?
您需要确保您拥有 URL Rewrite module installed 否则它不会工作,并且您会收到与 IIS 相关的错误,无法理解 web.config 中的 rewrite
部分。