2011-09-14 27 views
5

我使用51degrees API爲移動重定向移動子域名:http://51degrees.codeplex.com/重定向到使用51degrees

當檢測到移動設備,使用51degrees,我能夠從任何桌面頁面重定向到僅使用51degrees配置移動首頁。即http://www.mydomain.com/somepagehttp://m.somepage.com/default

我無法做的是重定向到同一頁面,即從http://www.mydomain.com/somepagehttp://m.somepage.com/somepaage

是否可以重定向到同一頁面?

+0

你可以分享你的51Degrees正則表達式/代碼做域名重定向請 – leen3o

回答

5

選項1:使用51degrees爲移動檢測部件只及導線上重定向自己。從你的web.config中刪除<redirect>元素,並嘗試在Global.asax文件是這樣的:

void Application_BeginRequest(object sender, EventArgs e) 
{ 
    if (HttpContext.Current.Request.Browser.IsMobileDevice) 
    { 
     Response.Redirect("http://m.mydomain.com" + Request.RawUrl); 
    } 
} 

選項2:在Web.config文件中<redirect>元素,添加屬性originalUrlAsQueryString=true。這將發送名爲origUrl到移動網頁給你重定向到請求頁面的移動版本的選項查詢字符串。

0

您可以在51Degrees.mobi User Guide的第2.1.2節中找到有關如何將其配置爲重定向到移動版本頁面的信息。

+2

請在你的答案中添加該部分的相關部分,該部分應該是獨立可讀的。現在,你只是告訴他別人有他的回答(更不用提鏈接腐爛)。 –