homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / RSS, ATOM, and Related Technologies
Forum Library, Charter, Moderators: bill & werty

RSS, ATOM, and Related Technologies Forum

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

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


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 = "";

$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" );



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

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.


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



Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / RSS, ATOM, and Related Technologies
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved