[英]url redirection in IIS not working for non existing pages
I had a page http://domain1.com/blog.aspx . 我有一个页面http://domain1.com/blog.aspx 。
This page I have deleted and created a website with a new domain just for this page. 我已删除此页面,并为此页面创建了一个具有新域的网站。
like below http://domain2.com/blog.aspx 就像下面的http://domain2.com/blog.aspx
Then I have added a rule in domain1.com web.config like below 然后我在domain1.com web.config中添加了如下规则
<rewrite>
<rules>
<rule name="Redirect blog" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^domain1.com/blog.aspx$" />
</conditions>
<action type="Redirect" url="http://domain2.com/blog.aspx" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
But I get 404 error while visiting http://domain1.com/blogpage.aspx 但是访问http://domain1.com/blogpage.aspx时出现404错误
How can I fix this issue? 如何解决此问题?
A few issues... 一些问题...
{HTTP_HOST} = The host name which is domain1.com, so it will never match your pattern {HTTP_HOST} =主机名domain1.com,因此它永远不会与您的模式匹配
Also you can do this pattern="^domain1.com/blog.aspx$"
the .
您也可以执行此pattern="^domain1.com/blog.aspx$"
.
need to be escaped. 需要逃脱。
Now you have to match also on the request_uri
to capture the page. 现在,您还必须在request_uri
上进行匹配以捕获页面。 Below should work. 下面应该工作。 Providing you are re-directing domain1.com/blogpage.aspx
to domain2.com/blog.aspx
提供您将domain1.com/blogpage.aspx
到domain2.com/blog.aspx
<rule name="Redirect blog" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll" >
<add input="{HTTP_HOST}" pattern="^domain1\.com$" />
<add input="{REQUEST_URI}" pattern="blogpage\.aspx$" />
</conditions>
<action type="Redirect" url="http://domain2.com/blog.aspx" redirectType="Permanent" />
</rule>
</rules>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.