Search code examples
phprssfeed

How make php recognize feed requests


I want to know if it possible for php recognize if the request made by client is a feed rss request to make a redirect. Exemple: a user add this link - www.example.com - to feedly, but the rss page are www.example.com/feed, if the requests made to "example" are html, the php show the index page, but if are a xml request, the php make a redirection to www.example.com/feed


Solution

  • I don't think it's possible, since calls can be made automatically by different browsers etc... The only way is similar to the one Feedly provides, which has a specific user agent "Feedly/1.0" so you can easily check if client is feedly by checking $_SERVER['HTTP_USER_AGENT']

    function IsThisClientFeedly()
    {
        return (strpos($_SERVER['HTTP_USER_AGENT'],'Feedly') !== false)?true:false;
    }
    

    see more info on Feedly http://www.feedly.com/fetcher.html