Hướng dẫn seo bằng mobile redirection

  • Thread starter Thread starter AdminAdmin is verified member.
  • Start date Start date
Admin

AdminAdmin is verified member.

Well-Known Member
Staff member
Administrator
Đơn giản là khi truy cập bằng mobile sẽ tự chuyển sub ảo m.domain.com thôi còn kết quả trên google vẫn là domain.com

Trước tiên hãy tạo 1 giá trị DNS là m và dns về ip hoặc cname host đang sử dụng.
Vào header đặt code trong <head></head>
HTML:
<script type="text/javascript">
<!--
if (screen.width <= 700) {
document.location = ".m.domain.com";
}
//-->
</script>
<script type="text/javascript">
<!--
if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
   location.replace("http://m.domain.com");
}
-->
</script>
Tức là tự chuyển hướng khi màn hình có độ phân giải ngang nhỏ hơn 700 px.
hoặc sử dụng hàm php
PHP:
<? if (
 stristr($ua, "Windows CE") or
 stristr($ua, "Mobile") ) {
 $DEVICE_TYPE="MOBILE";
 }
 if (isset($DEVICE_TYPE) and $DEVICE_TYPE=="MOBILE") {
 $location='m.domain.com/index.php';
 header ('Location: '.$location);
 exit;
 }
 ?>
Hoặc dùng .htaccess
PHP:
RewriteEngine On
# Check for mime types commonly accepted by mobile devices
RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^ http://m.yourdomain.com%{REQUEST_URI} [R,L]

Chúc bạn thành công!
 

Facebook Comments

Similar threads

cuongpro9x
Replies
1
Views
1K
trangpham2133
trangpham2133
Admin
Replies
0
Views
8K
AdminAdmin is verified member.
Admin
A
Replies
0
Views
616
alathuan2
A
Admin
Replies
0
Views
999
AdminAdmin is verified member.
Admin
Admin
Replies
0
Views
319K
AdminAdmin is verified member.
Admin
Back
Top