Forum Moderators: bakedjake

Message Too Old, No Replies

Redirecting PC and Mobilephone Users

how to redirect by user agent?

         

waynemac

4:35 pm on Nov 22, 2004 (gmt 0)

10+ Year Member



Gidday all, Im trying to have users access my site using the same URL by either PC or mobilephone...PC to phpwebsite folder and mobilephones to mobile folder.

I know the user agent arrays but just cant get anything to work. Then again I dont know whether to put what I have into htaccess or index.php/html.

Does anyone know the answers? Any advice, code, help would be appreciated.

Thanx, Wayne in Japan

mcavill

4:58 pm on Nov 22, 2004 (gmt 0)

10+ Year Member



I've got that working on one of my sites.

I have an include at the top of the page that gets the UA string, if it finds "smartphone" in it I serve out different content - that's on an ASP page.

I think the code was something like:

If(instr(Request.servervariables("HTTP_USER_AGENT", "SmartPhone")) then
response.redirect ....
end if

waynemac

5:09 pm on Nov 22, 2004 (gmt 0)

10+ Year Member



Hi Mcavill, looks promising.

Dont happen to have the full script floating around?

Also, wondering if there is any difference b doing it thru php or asp?

Wayne

bill

5:54 am on Nov 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yokoso waynemac!

If you're targeting DoCoMo phones then it won't matter whether the pages are ASP or PHP. I've been able to access both with my phones. It really depends what you're comfortable with.

I found it really tough to keep up with all the new phone's user-agents, so instead of sniffing an alternative is to put the URI for your i-mode site at the top of the page and simply hide it with CSS. This means one more click for phone users.