While I’m browsing using my K800i, very often that I’ve accidentally visit a non-mobile site with huge flash or huge content. That sucks, that costs, since mobile internet is rather expensive in my location. So after searching and testing, I’ve shared a simple hacks for your existing blog or web application to redirect mobile user that visiting your website to mobile-specific pages.

The hacks is for apache webserver only, but nginx or lighttpd server can use the same concept using their config syntax. Put the following config snippet on your website either using .htaccess or directy editing the apache config.

RewriteEngine On

#redirect mobile browser using HTTP_ACCEPT header
RewriteCond %{HTTP_ACCEPT} "text/vnd.wap.wml|application/vnd.wap.xhtml+xml" [NC]
RewriteCond %{HTTP_HOST} "!m.yourmobileurl.com" [NC]
RewriteRule (.*) http://m.yourmobileurl.com/$1 [L]

#some high-end phone sometimes support HTML, only its sucks
#add more browser user agent sig here
RewriteCond %{HTTP_USER_AGENT} (nokia|symbian|iphone|blackberry) [NC] 
RewriteCond %{HTTP_HOST} "!m.yourmobileurl.com" [NC]
RewriteRule (.*) http://m.yourmobileurl.com/$1 [L]

Using HTTP_ACCEPT header is much more simple rather than hitting the HTTP_USER_AGENT variables. I guess there’s the end of it, Have fun!