Killersites.com Homepage Welcome Guest   |   Register  |  Login
Login Name Password
  Search  
  Index  | Recent Threads  | Unanswered Threads  | Who's Online  | User List  | Help


Quick Go »

No member browsing this thread
Thread Status: Active
Total posts in this thread: 2
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 3094 times and has 1 reply Next Thread
Male phex
Stranger




Joined: Aug 12, 2008
Post Count: 6
Status: Offline
Reply to this Post  Reply with Quote 
smile page redirection

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?

[Dec 12, 2008 8:48:24 AM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Male shelfimage
Advanced Member
Member's Avatar

USA
Joined: Mar 24, 2005
Post Count: 3000
Status: Offline
Reply to this Post  Reply with Quote 
Re: page redirection

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
[Dec 12, 2008 9:20:03 AM] Show Printable Version of Post    View Member Profile    Send Private Message    mainewebworks    mainewebworks [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread