Have you created a mobile version of your site? Do you want to redirect your real site to mobile version if any one visit from mobile device?
Example:
I have a website. Url is : www.myweb.com
Also have a mobile version of this. Url: m.myweb.com
I want: If anyone go to www.myweb.com from mobile he will be redirect to m.myweb.com automatically.
Its not so hard. Lets do this :D
Javascript Method
Mobile phones have a small screen width. You can redirect
visitors to your mobile site if they have a screen width of less than or
equal to 800 pixels. Use this code:
<script type="text/javascript"> <!-- if (screen.width <= 800) { window.location = "http://m.myweb.com"; } //--> </script>
You will Change m.domain.com to your personal domain name.
To get the best results, you should have to test with various smart phones. Please remember however that if the user does not have javascript enabled, this will not work.
.htaccess redirects
Useing .htaccess file you can do this easily. You can easily do this to any web site created by any CMS (Wordpress,Joomla) useing .htaccess file.Put this code to your .htaccess file and change url:
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.myweb.com%{REQUEST_URI} [R,L]
This comment has been removed by a blog administrator.
ReplyDelete