我有FTP访问我的ASP.NET Websapce(IIS 7),并且在Web根文件夹中使用Web.config路由子域。 她看起来像这样:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="route www and emtpy requests" stopProcessing="true"> <match url=".*" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{HTTP_HOST}" pattern="^(www.)?example.com" /> <add input="{PATH_INFO}" pattern="^/www/" negate="true" /> </conditions> <action type="Rewrite" url="\www\{R:0}" /> </rule> <rule name="route to blog" stopProcessing="true"> <match url=".*" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{HTTP_HOST}" pattern="^blog.example.com$" /> <add input="{PATH_INFO}" pattern="^/blog/" negate="true" /> </conditions> <action type="Rewrite" url="\blog\{R:0}" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
正如你可以看到我有两个文件夹在我的根目录: “www”和“博客” 。 当我现在input“blog.example.com”时,任何方面都可以正常工作,但是当我点击某个链接时,我会转到“blog.example.com/blog”
我能做些什么来防止这种行为?
因为你redirect到blog.foo.com/blog,你需要redirect到FQDN(改为foo.con / blog)。