2012-06-04 20 views
1

我發現移動檢測和重定向腳本,但在「整個」站點級別,例如,如果您到達內頁(例如:www.site.com/this_page.php )與移動/智能手機/平板電腦,你被重定向到代理子域名網站,讓說m.site.com。移動重定向域級別,保留頁面url

這不適合我需要的東西,我正在尋找一些在瀏覽器/設備檢測上很好的東西,但是然後將您重定向到完全相同的頁面,但在子域上,使用上面的示例,它應該是: m.site.com/this_page.php,

有沒有這樣的腳本?

問候

回答

0

如果我理解正確的話,你應該能夠在你的網站的任何點使用的設備檢測腳本(PHP或其他)。例如,使用例如與51Degrees.mobi框架:

<?php 
include('51Degrees/51Degrees.mobi.php'); 

$IsMobile = $_51d["IsMobile"] == "True"; 
    if ($IsMobile) 
     redirect(m.site.com); 
    else 
     redirect(www.site.com); 
?> 

這可以嵌入索引的HTML內,但也可以放置在/this_page.php還有:

<?php 
include('51Degrees/51Degrees.mobi.php'); 

$IsMobile = $_51d["IsMobile"] == "True"; 
    if ($IsMobile) 
     redirect(m.site.com/this_page.php); 
    else 
     redirect(www.site.com/this_page.php); 
?> 

這是直到你放置代碼的地方。