Welcome to WebmasterWorld Guest from 54.163.40.152

Forum Moderators: bill & werty

Message Too Old, No Replies

Automagically Switching to RSS

I want a magic reroute to an RSS feed based on accept headers.

     

cmarshall

1:14 am on Oct 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Folks,

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:


<?php
$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" );
}
else
{
header ( "Location: xhtml_home.php$query" );
}
?>

teaperson

9:39 pm on Nov 7, 2005 (gmt 0)

10+ Year Member



One problem you'll run into is that there are a gazillion different RSS readers.

I personally think the best solution to not displaying hideous, confusing XML to users is to use an XSL stylesheet to render it as readable XML. This is what feedburner does. If you google xsl and rss, you'll get some good pointers.

cmarshall

2:48 am on Nov 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks!

Wildu.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month