简体   繁体   English

301在IIS上重定向?

[英]301 redirect on IIS?

i have tow websites eg "testsite.ir" and "testsite.com". 我有两个网站,例如“ testsite.ir”和“ testsite.com”。 as i know my web site is on Windows Server 2008, Microsoft-IIS/7.5 . 据我所知,我的网站位于Windows Server 2008,Microsoft-IIS / 7.5上。 how can i use 301 redirect to redirect users from .ir to .com? 如何使用301重定向将用户从.ir重定向到.com? can i use .htaccess file or i should use webconfig? 我可以使用.htaccess文件还是应该使用webconfig?

i use the code bellow in my webconfig, but nothing happen: 我在我的webconfig中使用下面的代码,但是什么也没发生:

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

Any help would be appreciated! 任何帮助,将不胜感激!

If you have remote access to the server you can do this within IIS. 如果您可以远程访问服务器,则可以在IIS中执行此操作。 You need to enable HTTP Redirect within IIS (add/remove windows features) before you can add a rule. 您需要先在IIS中启用HTTP重定向(添加/删除Windows功能),然后才能添加规则。 Once you've enabled it you can redirect the .ir site to the .com site. 启用后,您可以将.ir网站重定向到.com网站。 See here: http://www.iis.net/configreference/system.webserver/httpredirect 参见此处: http : //www.iis.net/configreference/system.webserver/httpredirect

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM