1

ドメインhttp://mosaically.comhttp://mosaically.com/を持つ ASP.NET MVC 4 Web サイトで、どちらも 200 OK 応答を返しています。SEO の理由から、mosaically.com に、スラッシュを使用して、mosaically.com/ への 301 リダイレクトを実行してもらいたいと考えています。MVC 4 でこれを行う方法はありますか? IIS で何かを試すよりも、MVC でこれを行うことをお勧めします。

4

3 に答える 3

1

たとえあなたがチャック・ノリスであったとしても、それはできないことがわかった グーグルは言う

http://googlewebmastercentral.blogspot.com/2010/04/to-slash-or-not-to-slash.html

「特にルート URL については、example.com は example.com/ と同等であり、Chuck Norris であってもリダイレクトできないのでご安心ください。」

于 2013-02-04T05:05:36.440 に答える
0

私はあなたがそのように使うべきだと思います

あなたの中でglobal.aspx

    protected void Application_BeginRequest()
        {
            string rudsiteurl = HttpContext.Current.Request.Url.AbsoluteUri;
            if (rudsiteurl.Contains("http://www.mosaically.com"))
            {
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", "http://www.mosaically.com/");
            }

        }

私はこれがあなたを助けると思います...

于 2013-02-04T05:26:33.167 に答える
0

Url Rewrite moduleIIS で を使用して、このタスクを実行できます。nice step by step articleこれを有効にする方法を次に示します。サンプルの書き換えルールは、web.config でどのように表示されるかを次に示します。

<system.webServer> 
    <rewrite> 
        <rules> 
            <rule name="CanonicalHostNameRule1"> 
                <match url="(.*)" /> 
                <conditions> 
                    <add input="{HTTP_HOST}" pattern="^www\.mosaically\.com$" negate="true" /> 
                </conditions> 
                <action type="Redirect" url="http://www.mosaically.com/{R:1}" /> 
            </rule> 
        </rules> 
    </rewrite> 
</system.webServer> 
于 2013-02-03T17:07:15.160 に答える