我主持了一个网站,我想由于各种原因http://mydomain.com自动redirect到http://mydomain.com/web同时仍然允许http://mydomain.com/foo.html被送达。
从IIS 7使用HTTPredirect我似乎正在创build一个无尽的redirect循环。 你有什么提示吗?
我假设你只想要/被redirect。 在这种情况下,请检查一个空的URL,然后redirect到/ web /,如以下web.config所示:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="Redirect to /web" stopProcessing="true"> <match url="^$" /> <action type="Redirect" url="/web/" redirectType="Found" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
如果您已将整个网站移至/ web /下,并希望将每个旧urlredirect到/ web /下的新url(除了那些具有匹配文件或目录的url),只需检查所有不以网页/不匹配文件和目录并redirect这些:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="Redirect to /web" stopProcessing="true"> <match url="^web/" negate="true" /> <action type="Redirect" url="/web{REQUEST_URI}" appendQueryString="false" redirectType="Found" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> </rule> </rules> </rewrite> </system.webServer> </configuration>