|
| Index | Recent Threads | Unanswered Threads | Who's Online | User List | Help |
|
|
| No member browsing this thread |
|
Thread Status: Active Total posts in this thread: 2
|
|
| Author |
|
|
Stranger Joined: Aug 12, 2008 Post Count: 6 Status: Offline |
Hi there. I want my website to be accessed by both ?pc and cell phones browsers?. Since the monitor sizes of both pc?s and cell phones are not equal, I have developed two index pages. 1) index.php for pc browsers 2) index2.php for cell phone browsers. Both pages are XHTML compliant. What I want is that when a visitor enters eg mysite.com from his cell phone browser, he should be automatically redirected to index2.php. How do I do that using PHP? |
||
|
|
Advanced Member USA Joined: Mar 24, 2005 Post Count: 3000 Status: Offline |
the only way to do that is to be able to identify the use agent being used. you might have to test for 100's of them and then redirect to the appropriate page. the usual way to serve a mobile device site is to have an alternate site at a subdirectory of your domain and provide a link there. for example, m.your-domain.com. People using a mobile device visit that URL. or try using a mobile stylesheet and when the server detects a mobile user agent, it is served the mobile stylesheet instead. In php, you can capture the user agent this way: <?php $ua_ok= $_SERVER['HTTP_USER_AGENT']; ?> $ua_ok is a variable assigned to the php string above. then you can test if( eregi( "Insert-Mobile-User-Agent-Name-Here", $ua_ok ) ) { header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.Your-Domain.com/index2.php"); exit(); ---------------------------------------- "The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo Save the developers<!> Maine Webworks |
||
|
|
|
|
|
Current timezone is GMT Mar 22, 2010 7:21:55 AM |