Go Back   CodingForums.com > :: Client side development > General web building > Building for mobile devices

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-15-2009, 03:30 AM   PM User | #1
nicky
Regular Coder

 
Join Date: May 2008
Location: Michigan
Posts: 216
Thanks: 10
Thanked 1 Time in 1 Post
nicky is on a distinguished road
Mobile browser detection and redirection

I'm trying to expand my website's compatibility to mobile devices. My website is www.inthedesigns.net, and I would like it to detect mobile browsers and redirect to http://m.inthedesigns.net.

I know javascript is out of the question since the majority of mobile devices either don't support it or it's turned off by default.

Is there a simple way of doing this, like through PHP or my .htaccess file?

Much thanks!
nicky is offline   Reply With Quote
Old 10-15-2009, 03:39 AM   PM User | #2
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
Quote:
Originally Posted by nicky View Post
I'm trying to expand my website's compatibility to mobile devices. My website is www.inthedesigns.net, and I would like it to detect mobile browsers and redirect to http://m.inthedesigns.net.

I know javascript is out of the question since the majority of mobile devices either don't support it or it's turned off by default.

Is there a simple way of doing this, like through PHP or my .htaccess file?

Much thanks!
http://httpd.apache.org/docs/2.2/rew...endent-content

Edit: I just find this:
http://detectmobilebrowsers.mobi/

best regards

Last edited by oesxyl; 10-15-2009 at 04:00 AM..
oesxyl is offline   Reply With Quote
Old 10-20-2009, 02:48 AM   PM User | #3
nicky
Regular Coder

 
Join Date: May 2008
Location: Michigan
Posts: 216
Thanks: 10
Thanked 1 Time in 1 Post
nicky is on a distinguished road
I couldn't implement the PHP coding in my header.php file. It kept saying there was an error.
nicky is offline   Reply With Quote
Old 10-20-2009, 09:46 PM   PM User | #4
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
What error?

There is also the media attribute you can use on the link tag when you bring in stylesheets so you can have a different one for mobile browsers. However obeying that is up to the browser, I believe the iPhone browser uses the screen media type and not the mobile one (as an example).
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Old 10-21-2009, 03:37 AM   PM User | #5
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
Quote:
Originally Posted by nicky View Post
I couldn't implement the PHP coding in my header.php file. It kept saying there was an error.
Quote:
Originally Posted by oracleguy View Post
What error?

There is also the media attribute you can use on the link tag when you bring in stylesheets so you can have a different one for mobile browsers. However obeying that is up to the browser, I believe the iPhone browser uses the screen media type and not the mobile one (as an example).
a guess:

Quote:
Warning: Cannot modify header information - headers already sent by (output started at...
if this is the case, you can't echo or print anything before the header line.

best regards
oesxyl is offline   Reply With Quote
Old 11-24-2009, 12:10 AM   PM User | #6
davemanjra
New to the CF scene

 
Join Date: May 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
davemanjra is an unknown quantity at this point
@nicky,

There are a few web services set up already which do this. we use handsetdetection.com

In some cases, rather than just detecting whether the person browsing is mobile or not, we customise our clients sites to be optimised to the screen size of the actual device.
davemanjra is offline   Reply With Quote
Old 07-02-2010, 01:50 PM   PM User | #7
ghost2012
New Coder

 
Join Date: Jan 2009
Posts: 26
Thanks: 3
Thanked 0 Times in 0 Posts
ghost2012 is an unknown quantity at this point
I use this as index.php and redirect it according to the device.

Code:
<?php
$mobile = $_SERVER['HTTP_USER_AGENT'];
$bberry = "BlackBerry";
$blackberry = 'http://blackberry.yoursite.com/';
$main = "default.php";
if ((strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry')) !== false)
{
header("location: $blackberry");
}
else
{
header("location: $main");
}
?>
This is the code I use in a PHP script that works perfectly for me.

Last edited by ghost2012; 07-02-2010 at 02:11 PM..
ghost2012 is offline   Reply With Quote
Old 12-17-2010, 10:09 PM   PM User | #8
raymonddenis
New to the CF scene

 
Join Date: Dec 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
raymonddenis is an unknown quantity at this point
You could also use a rewrite rule in .htaccess that would be something similar such as:

Code:
RewriteCond %{HTTP_USER_AGENT} (OneMobileUserAgent|AnotherMobileUserAgent|...)
RewriteRule (.*) $1?mobile=1 [L]
Just need to paste your mobileuseragent list in the condition and voila.


______________________
Assurance auto
raymonddenis is offline   Reply With Quote
Old 12-18-2010, 06:12 AM   PM User | #9
zinedinezidane
New to the CF scene

 
Join Date: Dec 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
zinedinezidane is an unknown quantity at this point
Ozeki Message server

Do any of you know how to receive messages using SMS gateway or Ozeki Message server?

I am able to send SMS but not receive.
zinedinezidane is offline   Reply With Quote
Old 01-03-2011, 08:31 PM   PM User | #10
snaker190
New to the CF scene

 
Join Date: Dec 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
snaker190 is an unknown quantity at this point
Quote:
Originally Posted by zinedinezidane View Post
Do any of you know how to receive messages using SMS gateway or Ozeki Message server?

I am able to send SMS but not receive.
Ya i am having the same problem can enny one help



______________________
Naruto Shippuden
snaker190 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:28 AM.


Advertisement
Log in to turn off these ads.