I use a smart index file to route cell phones that hit my main URI into WML and XHTML-MP pages. I'm wondering if I can do the same for RSS, based, maybe upon HTTP ACCEPT headers. I'll do a bit of experimenting, but I find that I often miss that one whacky browser that causes the whole thing to go pear-shaped.
I'd be interested in knowing if this is possible, and, if so, whether or not it is advisable.
Here's how the site works now:
If a standard browser hits it, then we go to the normal XHTML page.
If a cellphone hits it, then we head for WML. However, if the cell phone will accept XHTML-MP, it goes to the XHTML-MP page.
I would like to add an RSS aggregator to that list. That way, I don't have to have these annoying XML links that scare the bejeezus out of my visitors when their page goes blank or fills with fluent Martian.
Here's the code I use for the cell phone switch:
$http_accept = preg_split ( "/\s*\,\s*/", $_SERVER['HTTP_ACCEPT'] );
foreach ( $http_accept as $type )
$type = preg_replace ( "/\s+/","", $type );
$type = preg_replace ( "/\;.*$/","", $type );
$accept[$type] = true;
$language = 'xhtml';
$query = "";
if ( $_SERVER['QUERY_STRING'] )
$query = "?". urlencode ( $_SERVER['QUERY_STRING'] );
if ( $accept['text/vnd.wap.wml'] )
$language = 'wml';
if ( $accept['application/xhtml+xml'] )
$language = 'xhtml_mp';
if ( $language == 'wml' )
header ( "Location: wml.php$query" );
elseif ( $language == 'xhtml_mp' )
header ( "Location: xhtml_mp.php$query" );
header ( "Location: xhtml_home.php$query" );