I’m looking to make a Sony PSP optimized website, but I want it so that it can only be viewed by the PSP and if viewed in a normal pc internet browser, you have a message saying “please visit us using your psp” or something along those lines. How do I do that?
This is a very cool question and one that turns out to be pretty easy to solve once you realize that all Web browsers return information about themselves using a CGI environment variable called HTTP_USER_AGENT.
I wrote a quick little shell script that displays the calling environment when accessed via a browser and used that for testing:
echo "Content-type: text/html"
When this script is invoked from Apple’s Safari browser, for example, I see:
HTTP_USER_AGENT=Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en)
AppleWebKit/417.9 (KHTML, like Gecko) Safari/417.8
but when I go to my Sony Playstation Portable (PSP) and use its built-in Web browser to access the very same script, I see:
HTTP_USER_AGENT=Mozilla/4.0 (PSP (PlayStation Portable); 2.00)
There’s also a second variable you could check for that I’ve only ever seen with the PSP browser:
I talk about how to accomplish this sort of conditional page delivery in my book Creating Cool Web Sites with HTML,XHTML and CSS too, as it happens!
Hope that gets you moving in the right direction!