Web配置重定向 [英] web config redirects

查看:78
本文介绍了Web配置重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试通过web.config将文件夹重定向到根URL.如果数小时内尝试一切都没有运气.

我能够使用这些规则将http://sample.com重定向到http://www.sample.com

Hi,

I''m trying to redirect a folder to the root url through the web.config. If tried everything for hours with no luck.

I am able to redirect http://sample.com to http://www.sample.com using these rules

<rule name="Redirect to WWW" stopProcessing="true">
    <match url=".*" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^sample.com$" />
    </conditions>
    <action type="Redirect" url="http://www.sample.com/{R: 0}" redirectType="Permanent" />
</rule>



我只是无法从www.sample.com/folder/{everything here}重定向到www.sample.com/

我尝试到处寻找并尝试使用与上述相同的格式,但是似乎没有任何效果.

预先感谢,
Brian



I''m just not able to redirect from www.sample.com/folder/{everything here} to www.sample.com/

I''ve tried looking everywhere and tried using the same format as above but nothing seems to work.

Thanks in advance,
Brian

推荐答案

" / > < /conditions > < 动作 =" 重定向" url http://www.sample.com/{R:0}" redirectType =" > < /rule >
" /> </conditions> <action type="Redirect" url="http://www.sample.com/{R: 0}" redirectType="Permanent" /> </rule>



我只是无法从www.sample.com/folder/{everything here}重定向到www.sample.com/

我尝试到处寻找并尝试使用与上述相同的格式,但是似乎没有任何效果.

预先感谢,
Brian



I''m just not able to redirect from www.sample.com/folder/{everything here} to www.sample.com/

I''ve tried looking everywhere and tried using the same format as above but nothing seems to work.

Thanks in advance,
Brian


好一会儿,我想通了.

OK after some time, I figured it out.

<rule name="your name here" stopProcessing="true">
<match url="^foldername/(.*)


" ignoreCase false" / > < 动作 =" 重定向" redirectType 永久" url =" http://www.examplesite.com/{R:1}" / < >
" ignoreCase="false" /> <action type="Redirect" redirectType="Permanent" url="http://www.examplesite.com/{R:1}" /></rule>


这篇关于Web配置重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆