raksmart活动促销

分享

写回答

发帖

麻烦帮忙翻译一下,谢谢!(已解決問題)

 关闭

英文翻译专版 英文翻译专版 2517 人阅读 | 4 人回复

发表于 2010-12-20 16:26:58 | 显示全部楼层 |阅读模式

我在根目录新建了个子目录myweb,绑定了网站www.myweb.com。
现在http://www.myweb.com可以访问网站,而通过子目录myweb也可以访问,http://www.myweb.com/myweb
如何让http://www.myweb.com/myweb 301跳转到 http://www.myweb.com?
通过web.config怎么写跳转代码?

回答|共 4 个

a7898585

发表于 2010-12-20 18:44:58 | 显示全部楼层

................专业性太强了,翻译了,直接给你答案把

[ 本帖最后由 a7898585 于 2010-12-20 06:49 PM 编辑 ]

a7898585

发表于 2010-12-20 18:48:43 | 显示全部楼层

方法如下:

在网站的根目录下新建web.config文件并将一下代码加入到文件中。

以下为引用的内容:
<configuration>
   <system .webServer>
      <rewrite>
         <rules>
            <rule name="WWW Redirect" stopProcessing="true">
              <match url=".*" />
                 <conditions>
                    <add input="{HTTP_HOST}" pattern="^aogei.com$" />
                 </conditions>
              <action type="Redirect" url="http://www.aogei.com/{R:0}"
                   redirectType="Permanent" />
            </rule>
         </rules>
      </rewrite>
   </system>
</configuration>


如果你的网站已经有了web.config文件。修改你的web.config文件。在web.config文件… 中的最后一行后面添加以下代码:

以下为引用的内容:
<rule name="WWW Redirect" stopProcessing="true">
              <match url=".*" />
                 <conditions>
                    <add input="{HTTP_HOST}" pattern="^aogei.com$" />
                 </conditions>
              <action type="Redirect" url="http://www.aogei.com/{R:0}"
                  redirectType="Permanent" />
            </rule>


最后需要提醒的是在添加或者修改web.config时,别忘了把我的域名aogei.com修改成所要跳转的域名。

一个很重要事就是要使用“Permanent”(永久)定向。这样做很有帮助的是,任何人链接你的网站是使用的非www地址时,直接使搜索引擎的机器人在抓取作为永久移动的链接。新的url将会被定义为正确的地址,因此旧的非www地址将不会被索引

评分

参与人数 1金币 +4 银币 +10 收起 理由
kingto + 4 + 10 助人为乐

查看全部评分

kingto

发表于 2010-12-20 20:29:46 | 显示全部楼层

感谢楼上助人为乐

原文翻译一下
Hello,

I created a subdirectory called 'myweb' under root directory, and my website
www.myweb.com was directed there .
However, I can access it through both
http://www.myweb.com and http://www.myweb.com/myweb,
i'd just like to know how i can make it available that use 301 to redirect
http://www.myweb.com/myweb to http://www.myweb.com? What should I modify or add in the web.config file?

Thank you very much
.


sealoo

发表于 2010-12-20 22:24:46 | 显示全部楼层

感谢3楼,不过那个不行哦,我要调整子目录,不是域名。
感谢4楼,现在就给发过去看看。
您需要登录后才可以回帖 登录 | 注册

本版积分规则