I have a help section on a web site, which for now I want it to redirect to another place. The rest of the site should stay the same, which means that only the help section/content should make the user go to another site:
我在一个网站上有一个帮助部分,现在我想让它重定向到另一个地方。站点的其余部分应该保持不变,这意味着只有帮助部分/内容才能让用户访问另一个站点:
device.domain.net/collection/hgkhghj should return to device.domain.net/collection
device.domain.net/collection/hgkhghj应该返回device.domain.net/collection。
I can have anything at the place of hgkhghj . If i am writing device.domain.net/collection then it should return device.domain.net/collection
我可以在hgkhghj的地方找到任何东西。如果我正在写device.domain.net/collection,那么它应该返回device.domain.net/collection。
<rule name="Help Redirect" stopProcessing="true">
<match url="(.*)/collection(.*)" ignoreCase="true" />
<action type="Redirect" url="http:/device.domain.net" appendQueryString="false" redirectType="Permanent" />
</rule>
but currently it is returning to device.domain.net.
但目前它正在返回device.domain.net。
I want to make one more Rule in which if i enter device.domain.net/gcfhgg then it should return to device.domain.net.
我想再做一个规则,如果我输入device.domain.net/gcfhgg,它就会返回device.domain.net。
<rule name="Help Redirect" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
<action type="Redirect" url="http://device.domain.net" appendQueryString="false" redirectType="Permanent" />
</rule>
But it is not working.
但它不起作用。
1 个解决方案
#1
0
For your first rule you could use the following (assuming it is on the same domain):
对于您的第一个规则,您可以使用以下(假设它位于同一域):
<rule name="Help Redirect" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^collection/(.*)" />
<action type="Redirect" url="collection" appendQueryString="false" redirectType="Permanent" />
</rule>
If this is on another domain you will need ARR installed as well. Your second rule is more complicated as it looks as if you are attempting to perform a redirect only if you hit a 404 page. This is something I have never done using rewrite rules. Is there a reason for doing this as opposed to showing a custom 404 page?
如果这是在另一个领域,您也需要安装ARR。您的第二个规则更复杂,因为它看起来就好像您试图执行一个重定向,除非您点击了一个404页面。这是我从来没有使用重写规则做过的事情。是否有理由这样做,而不是显示自定义的404页面?
#1
0
For your first rule you could use the following (assuming it is on the same domain):
对于您的第一个规则,您可以使用以下(假设它位于同一域):
<rule name="Help Redirect" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^collection/(.*)" />
<action type="Redirect" url="collection" appendQueryString="false" redirectType="Permanent" />
</rule>
If this is on another domain you will need ARR installed as well. Your second rule is more complicated as it looks as if you are attempting to perform a redirect only if you hit a 404 page. This is something I have never done using rewrite rules. Is there a reason for doing this as opposed to showing a custom 404 page?
如果这是在另一个领域,您也需要安装ARR。您的第二个规则更复杂,因为它看起来就好像您试图执行一个重定向,除非您点击了一个404页面。这是我从来没有使用重写规则做过的事情。是否有理由这样做,而不是显示自定义的404页面?