私のサイトのaspネットページはwww.mydomain.comにあり、ブログはwww.mydomain.com/blog内にありました。ブログをサブドメインに移動する必要があったため、ブログ内の任意のページの呼び出しを新しいサブドメインにリダイレクトするモジュールを作成する必要があります。
私のマシンでは機能しますが、共有ホスティングにアップロードすると機能しません。何が悪いのか考えてみませんか?
私は次のコードを書きました
public void ProcessRequest(HttpContext context)
{
string sourceUrl = @"www.mydomain.com/blog";// @"localhost:51393/blog"
string destinationUrl = @"blog.mydomain.com/blog";
string currentLocation = context.Request.Url.AbsoluteUri;
if(currentLocation.ToLower().Contains(sourceUrl))
{
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.StatusCode = 301;
System.Web.HttpContext.Current.Response.AddHeader("Location", currentLocation.Replace(sourceUrl, destinationUrl));
System.Web.HttpContext.Current.Response.End();
}
}
そして、これらのハンドラーを追加しました
<httpHandlers>
<add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory" />
<add verb="*" path="*" type="MyHandler,App_Code.dll"/>
どんな助けでも深く感謝します。
私はそれがこの1つのhttpHandler-サブフォルダの問題にかなり似ていることを知っていますが、それは機能しませんでした。