Hi,

Is there a way to stop Drupal from generating RSS feeds? or Maybe make sure the Web search engines do not index the RSS feeds?

I tried putting Disallow: /feed in robots.txt but it seems yahoo and google both still are indexing the feeds still.

Comments

FlemmingLeer’s picture

Hi Cursor,

You have to find all the places on your site that generates feeds and list them. You cannot as you discovered use kind-of-wildcards.

Xenu links checker displays all the urls generated by your site.

one to block is
Disallow: /node/feed
another is
Disallow: /blog/feed

It would also be advised that you exclude archive, if you use archive or else a search engine might get trapped on the site.
I just ran xenu links checker and it went back to 1999 although I just started my homepage this week.

Disallow: /archive

You can find Xenu links checker here and it´s free:
http://home.snafu.de/tilman/xenulink.html

If you don´t wan´t a specific search engine to index, list that engine before the default supplied from drupal http://drupal.org/node/22265 :

I don´t know if Googlebot can filter sub directories (e.g. Disallow : /feed/), but currently this does seem to matter regarding rank in google

User-agent: googlebot
Disallow: /node/feed
Disallow: /blog/feed
Disallow: /aggregator/sources
Disallow: /tracker
Disallow: /comment/reply
Disallow: /node/add
Disallow: /user
Disallow: /files
Disallow: /search
Disallow: /book/print
Disallow: /archive
Disallow: /trackback

User-agent: *
Crawl-Delay: 10
Disallow: /aggregator/sources
Disallow: /tracker
Disallow: /comment/reply
Disallow: /node/add
Disallow: /user
Disallow: /files
Disallow: /search
Disallow: /book/print
Disallow: /archive
Disallow: /trackback

You should be aware that inktomi (Yahoo) recently bought http://blo.gs and inktomi automatically injects your feed to that page.

links:
robots.txt checker
http://www.searchengineworld.com/cgi-bin/robotcheck.cgi

misconfigurations in robots.txt
http://www.searchengineworld.com/misc/robots_txt_crawl.htm

kkobashi’s picture

The use of robots.txt is a SUGGESTION to user agents. Don't take it to mean that they will follow your advice. There are user agents out there that will ignore robots.txt entirely.

Thus, while this may cause *some* user agents from crawling your site, it won't stop *all*. To solve the *all* case you need to hack the Drupal XML/RSS code and disable it.

Kerry Kobashi

tomcatuk’s picture

It's also worth baring in mind that blocking something in robots.txt won't actually stop GoogleBot (or whatever) from following the links to RSS feeds. Obviously hiding the icon with CSS doesn't stop it either. Some people may ask why this matters at all. For me, it's about crawl budget. If GoogleBot is wasting time crawling through RSS, it's not spidering the content I want it to.

sillygwailo’s picture

The way I did it for my personal site is to hack the Node module.

Find node.module, edit it, then look for the line

function node_feed($nodes = 0, $channel = array()) {

and insert the following two lines just below:

  drupal_not_found();
  return;

Basically it returns a 404 error indicating to search engines and other things that will take in the RSS feed that it's unavailable (either temporarily or permanently). I've only tested this with 4.5, but should work in 4.6. Note that every time you upgrade your Drupal install, you'll have to make the changes again. Ideally there should be some permissions around accessing feeds, to make it a little more flexible for site administrators.

(Username formerly my full name, Richard Eriksson.)

vikramdhani’s picture

hey do you know where can i find this line in node.module but i just tried and found like a billion lines code in node.module
im not a hardcore programmer can you please help me

How can i stop rss feeds showing up on search engine

Thank You

rgammon’s picture

I tried modifying node.module and common.inc as recommended in thread http://drupal.org/node/28336

But when I load page in Safari I still get RSS icon in URL bar and access to the feed.

Do I need to restart Drupal and how?

Or do I just need to wait a certain amount of time for something to refresh somewhere out there on the net?

behindthepage’s picture

I killed the RSS Feeds on my site by hacking one of the includes as follows:

common.inc found in the includes folder.

There are two functions to comment out ie. /* content to be commented out */

function format_rss_channel (which formats a RSS channel)
Comment out lines 692 - 708

function format_rss_item (which formats a RSS item)
Comment out lines lines 715 - 743

Once these are commented out (or deleted) ALL feeds will be blank.

Silent as the grave.....

Regards
Geoff

cursor’s picture

Hey Guys,

Thanks for hacks.. they work well.. But I do think it should be a feature in Drupal maybe in the Settings section.. a small question like "RSS Feeds" - Enable/Disable should be fine. I have put a feature request for it.

Thanks again.!

smilodon’s picture

I think this should be done from admin side with a button. Iv already found an issue too about it, so i hope to see it in the next version.
This hacking seemed to work, so thank you gpdinoz and others who suggested different ways how to kill the button. :)

vikramdhani’s picture

hi can you please help me commenting out the lines
function format_rss_channel (which formats a RSS channel)
Comment out lines 692 - 708 means function format_rss_channel is the line number 692 and can you tell which will be the lin number 708

and same thing for the function format_rss_item

i m sorry i dont know php so if you can help me out
thanks

jjamerican’s picture

I opened the specified file in 5.0 and the specified lines did not appear to relate the RSS feed. Was this a 4.7 specific fix?

-On a side note-

I am suprised at the lack of understanding of the desire to disable RSS. Some sites are only intended to disseminate static content.

I really agree that this should be a part of the next release, the ability to completely disable RSS with a single disable function.

jjamerican

keto-1’s picture

I used the hack common.inc method which seems to work great at disabling the rss function. However, I am still showing the xml button on every taxonomy page that I have. Here is an example:

http://www.freeonlineresearchpapers.com/taxonomy/term/34

(you will have to scroll to the bottom)

Any ideas on how to remove this from the theme all together?

Thanks for any advise!

behindthepage’s picture

If you find the following class in your style sheet

.xml-icon

and change it to the following
display:none;

and it won't display. I think that is what I did. Either that or hack the the module and remove where it is generated.

The css solution is better for future upgrades cause you will keep your style sheet.

Regards
gpdinoz

"If we can see further it is because we stand on the shoulders of giants"

Regards
Geoff

kkobashi’s picture

The CSS trick to hide the icon is a great solution to avoid bots following into the anchor tag for the icon. Using this with the solution to return a 404 error on the node_feed works great.

I agree, we need a feature that turns off RSS feeds from the admin panel.

Kerry Kobashi

kkobashi’s picture

Don't forget to turn off off XML/RSS from link style sheet in node.module. If you don't, you will get links in your pages.

Here's the rough area you need to turnoff:

      function node_page_default() {
      $result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), variable_get('default_nodes_main', 10));

      if (db_num_rows($result)) {
       /* Kerry - turn off to avoid placing link to xml/rss in page
         drupal_add_link(array('rel' => 'alternate',
           'type' => 'application/rss+xml',
           'title' => 'RSS',
           'href' => url('node/feed', NULL, NULL, TRUE)));
       */

Kerry Kobashi

drudogg’s picture

function node_page_default() {
$result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), variable_get('default_nodes_main', 10));

if (db_num_rows($result)) {
/* Kerry - turn off to avoid placing link to xml/rss in page
drupal_add_link(array('rel' => 'alternate',
'type' => 'application/rss+xml',
'title' => 'RSS',
'href' => url('node/feed', NULL, NULL, TRUE)));
*/

where are two missing brackets? -> }
btw if this is function where is calling this function? if you remove only function calling this function return errors... if you turn off errors will be only hidden but will be... kkobashi ?

fuzzie’s picture

The CSS trick worked perfectly for me....thanks

B.X’s picture

need:

.main-content .xml-icon, .main-content .feed-icon {
display: none;
}

TheWhippinpost’s picture

A word of caution if using display: none to hide the link: Bots will still crawl the link as it is still written within the source code of the page... albeit not visible to the user.

Mike
------------------------------------------------------------------------------------------
A simple thanks to those that help, a price worth payng for future wealth.

mdroste’s picture

Hi,

please, can you explain me:

why do you want stop Drupal generating a RSS Feed?
why you don't want the search engines to index the RSS Feed?

With these Features I got far more traffic and better search engine results on my web pages.

--
go with us

--
mdwp*

behindthepage’s picture

Here are examples of sites that you don't want RSS feeds.

Business site that has a public area and a private area that only their salesmen can log into to submit and get confidential information.

An organisation with restricted membership has a site for their members.

gpdinoz
"If we can see further it is because we stand on the shoulders of giants"

Regards
Geoff

laura s’s picture

We have at least one site that would greatly benefit from being able to turn off RSS. As it is, we turned off all anonymous access since, at the time, taxonomy access was bypassable via rss.

Laura
===
pingVisionscattered sunshine

_____ ____ ___ __ _ _
Laura Scott :: design » blog » tweet

flaviovs’s picture

Laura, you can use the trick I posted here, overriding theme_xml_icon() that is. If there's no link, nobody can click to the feeds.

If you're concerned about direct incoming links to feeds, for a final hackless solution, you can deny feed requests on Apache (or the webserver you use).

If memory serves, in Apache it would be something like this:

<LocationMatch ".*/feed$">
   Order Deny,Allow
   Deny from all
</LocationMatch>

I realize that this is not an actual solutions, but it works. The only trace of feeds after applying these tricks are on the <link rel="alternate"> header, which still will be pointing to feed URLs. You can leverage this at least for Google by including the following lines on your robots.txt:

User-Agent: Googlebot
Disallow: /*/feed$

It's sad we need such hassle to do a simple thing. Of course, a general on/off must be implemented.

Flávio Veloso
Nacional Digital | Emprego e Carreira Online

B.X’s picture

<LocationMatch ".*/feed$">
Order Deny,Allow
Deny from all
</LocationMatch>

in htaccess? hm... Internal Server Error for all site...

sillygwailo’s picture

Private content does not appear in public RSS feeds, so disabling the RSS feeds means disabling it for those who want to use their RSS aggregator to read the site (even for private content, which securesite lets you do).

(Username formerly my full name, Richard Eriksson.)

keto-1’s picture

Yeah, I think you are right. Why would I want to do anything that would hender my search engine results. Thanks for your reply!

- keto

flaviovs’s picture

You can hack your theme and put virtually anything as the XML icon. No need to change Drupal code, as it's too dangerous.

Just override theme_xml_icon($url). For instance, in PHPTemplate you can create a template.php file an put the following to remove the XML link/icon completely:

function phptemplate_xml_icon($url)
{
        return '';
}

Notice that no link == search engine spider can't find feed pages (unless someone links to them on other websites, of course). This is a simple, hackless way of turning off RSS feeds in Drupal that is working nice for me.

Flávio Veloso
Nacional Digital

vikramdhani’s picture

hey were will i be able to find the file template.php

ricot’s picture

Update for version 4.7.2 (note the change from xml to feed):

<?php
  function theme_name_feed_icon($url) {
  return;
  }
?>

Replace theme_name with the name of your theme and place in template.php in your theme's directory (create it if it does not exist). This method works like a charm for me, and I've seen no problems with it.

Riku

GreenLED’s picture

I enjoyed this bit of code. It does work very well. It did remove the icon. The RSS is still created, which is perfect for my situation because I'm not so apposed to having the feed as I hate having that icon sitting randomly in the content area. Thanks!

» Respectfully, GreenLED
» Stable Files . net

GreenLED’s picture

This code did work, but I just noticed, every time a form is submitted instead of arriving at the confirmation page or the page that is supposed to appear afterwords with a confirmation message you get a white page. It does not matter what form you're filling out whether it be a settings for or some other form. So, I would not use this now. This is horrible, because it works very well. I will have to look for a different solution.

» Respectfully, GreenLED
» Stable Files . net

GreenLED’s picture

I basically answered my own question. I had to many "<?PHP" tags which
apparently was re-sending the headers, removed them from another script
I was running, everything is beautiful now! Thanks! Check it out...

Huge Error Database Server(In Development) (2008.06.25)

» Respectfully, GreenLED
» Stable Files . net

gearhead’s picture

I tried changing node.module and common.inc with the above suggestions of commenting out the code and that worked to stop feed page displaying but the icon and the link were still at the bottom of the page here.
http://www.musclecarsociety.com/muscle-cars

The link is what I wanted to get rid of so bots would not find it and try to crawl it. This code worked. I put it in and the icon and link was gone.

Flávio is right this is a very easy way to shut of RSS feeds.

Gear Head

ergophobe’s picture

I was asking myself the same question this morning. Glad to see it here.

Shouldn't the legit SEs respect the rel="nofollow" attribute? So if you have that in all your /feed links, wouldn't that solve the issue?

It seems like that would give the best of both worlds for people who would want to offer feeds but don't want a duplicate content penalty in the SEs.

BTW, if drupal served up feeds with the correct mime type (application/rss+xml) the SEs would ignore this entirely. Unfortunately, FF and IE would ask you if you want to download the file, so you wouldn't be able to check the feed easily in your browser). Not sure if that's still true with FF 1.5

So I've done this in /themes/theme_name/template.php


function theme_name_xml_icon($url)
{
  if ($image = theme('image', 'misc/xml.png', t('XML feed'), t('XML feed'))) {
    return '<div class="xml-icon"><a href="/'. check_url($url) .'" rel="nofollow">'. $image. '</a></div>';
  }

}

Obviously, in the file name and the function name, replace "theme_name" with the name of your theme that gets the nofollow attribute.

Yosemite Explorer - hiking and climbing in Yosemite (drupal)

mcduarte2000’s picture

I found a website stealing all my recent content using my RSS (my website is a poetry forum).

My users aren't happy at all with this... :(

Miguel Duarte

Webmaster of: Lisbon Guide & Love Poems

geme4472’s picture

I know, naive question.

I have a 4.6 site that is password protected, with no unauthenticated users allowed. I don't want any bot to index my site, nor steal my RSS, nor take my lunch money.

I have pointed google at my site and found nothing, but I suspect that means very little. Do I need to take action??

Thanks in advance.

Sam J Hain’s picture

I can't seem to find in any of the css files where I can disable RSS/XML. I run a private website and require users to be logged in to view any and all content, making drupal generated RSS feeds unusable.

I just want to remove the XML icon from being displayed or whatever it takes to remove the feed feature completely. I have manually created a public RSS feed and wish not to confuse our subscribers with more links.

So in summary, I would like to be able to do the following:

TURN OFF ALL DRUPAL GENERATED FEEDS (useless unless user is logged in, feed readers do not know how to log in)

PREVENT XML ICON FROM BEING DISPLAYED

I do not want to use additional modules in order to disable something that should be a module.

Version 4.6

Any help would be very greatly appreciated ;)

drpratten’s picture

To disable RSS logos both in the address bar and on pages in Drupal 5.1 :

Edit theme.inc to disable feed icons

function theme_feed_icon($url) {
//  if ($image = theme('image', 'misc/feed.png', t('Syndicate content'), t('Syndicate content'))) {
//    return '<a href="'. check_url($url) .'" class="feed-icon">'. $image. '</a>';
//  }
}

AND also edit common.inc

function drupal_add_feed($url = NULL, $title = '') {
  static $stored_feed_links = array();

/*  if (!is_null($url)) {
    $stored_feed_links[$url] = theme('feed_icon', $url);

    drupal_add_link(array('rel' => 'alternate',
                          'type' => 'application/rss+xml',
                          'title' => $title,
                          'href' => $url));
  }*/
  return $stored_feed_links;
}
Metusela’s picture

Why isn't this a simple option in Administer>>Content Mamagement>>RSS Publishing ???

Just a simple option ti deactivate the RSS-feed. Or even better: Ability to select what should be put out as feeds i.e. if I want a feed om my news-stories and my blog, but not the forum or my book.

Maybe that's too much to ask...

NikLP’s picture

There's plenty of people who want to turn off RSS altogether - if people *still* need another example, how about a site that will clearly be used primarily by people who have *no idea* what RSS is, or care? Putting a funny looking icon on the site, that renders a load of gibberish when clicked upon, can hardly be regarded as a sensible option in that case.

+1 for this idea - perhaps someone can make a patch or something?

mrsocks’s picture

Thanks, these worked for me.

Though I am not clear if this removes any access to search engines indexing this content as well .... for just rss feeds.

Will the site still be indexable for the static content?

B.Janssen’s picture

First off, thank you for scrying the source. But do you or any other here have an idea how to do it on a per site base? I'm a newbie to Drupal and I have the intention to move at least two sites from a proprietary CMS to Drupal. Since the sites are related, I want to do a multi-site setup and so far tests are looking good. However, basically I want one site to have a feed, the other one to not have a feed. Actually, it is more complicated than that but isn't that always the case? Ideally I would like to be able to enable/disable feeds based on content type and user roles, e. g. news are fed to all, articles are fed to registered users and special features are not syndicated at all.

Is there any module that does that already or do I have to do it myself? Maybe there is a non-obvious Drupal-way of doing this? If not, where would be a good point to start to break out this functionality?

Regards

sergserv’s picture

Worked for me. Thanks

mrgoltra’s picture

This doesn't work for 5.2 using Opera and when I put in my url site.com/node/feed. Shows up.

deserttopping’s picture

I'm new to Drupal, and I can't help but wonder:

This thread started in '05.

Disable RSS still isn't incorporated as a feature?

What gives??

cendion’s picture

I think a simple "RSS Feeds = Disable" in the admin interface would be good for those who uses Drupal for private membership communitys where RSS is not used or desired. Otherwise, I think RSS feeds are great.

tvs_guy’s picture

Seems an RSS area within each content type would work better, along with a permissions setting for this. For instance: in each content type, at the end have a default option for "create RSS entry." Then, for when Drupal is serving pages, you could also show RSS feeds based on permission. Example: an anonymous user won't be able to discover the RSS feed, in particular search engines and the like.

For those that doubt the need for such a feature, here's another reason: The Views module provides a way to structure a very specific set of fields and filters to make a particular kind of RSS feed. This is very useful--much more than the "generic dumping" of info that's built in. Furthermore, if someone is routing a feed through a service such as Feedburner, you wouldn't want the un-processed feed to be broadcast to users.
-=tvswebserver.com=-

800series’s picture

This INABILITY to turn off RSS feed generation, in a simple user-friendly way, has me scratching my head.

Surely I'm not the only webmaster who doesn't want his content splayed across search engine sites.

I realize I'm at a point in Drupal where the learning curve is steepening; it's good to be getting my hands dirty. But RSS FEEDS ON -- Not just by default, but with no way to disable them without hacking php files? (Which I'm not ready to do)

I beseech thee Drupal developers, this is perhaps the only major issue I think, "I can't believe they designed it that way. I must be wrong."

Please make me wrong. : )

deserttopping - May 7, 2007 - 22:54

I'm new to Drupal, and I can't help but wonder:

This thread started in '05.

Disable RSS still isn't incorporated as a feature?

What gives??

dfrake’s picture

I was a little bit bothered about turning the feed off... maybe this interests some other users.

Drupal 5.1 ONLY!!!

Replace 'function drupal_get_feeds' in 'common.inc'

function drupal_get_feeds($delimiter = "\n") {
  if (variable_get('feed_enabled', 1) != 1) {
    return;
  }
  $feeds = drupal_add_feed();
  return implode($feeds, $delimiter);
}

Insert into 'node.module' on Line 2382, after the Line containing '$feed_url = url('rss.xml', NULL, NULL, TRUE);'

if (variable_get('feed_enabled', 1) != 0) {
  drupal_add_feed($feed_url, variable_get('site_name', 'Drupal') .' '. t('RSS'));
}

Insert in system.module at Line 761, after the Line containing 'function system_rss_feeds_settings() {'

    $form['feed_enabled'] = array(
      '#type' => 'checkbox',
      '#title' => t('RSS Feed enabled'),
      '#default_value' => variable_get('feed_enabled', 1),
      '#tree' => FALSE,
      '#description' => t('Check here if you want the RSS Feed to be enabled.')
    );

Now, when you go to Content Managment > RSS Publishing, you will see a shiny new checkbox 'RSS Feed enabled'.
Switch it off and your RSS Feed should be gone an vice versa!

I don't take any responsibility for any of these modifications, you apply them at your own risk!
Worked without any Problems for me.

menneke’s picture

For the second patch, do you mean:

In 'node.module' on Line 2382, after the Line containing '$feed_url = url('rss.xml', NULL, NULL, TRUE);' replace the line containing

drupal_add_feed($feed_url, variable_get('site_name', 'Drupal') .' '. t('RSS'));

with

if (variable_get('feed_enabled', 1) != 0) {
  drupal_add_feed($feed_url, variable_get('site_name', 'Drupal') .' '. t('RSS'));
}

Sorry for my clumsy formatting, I'm pretty new to this...

B.t.w. if after the modifications you get a blank page when reloading your site, it could be because of ghost characters (caused by copy/paste) where the identations are. Just delete the indentations in your code (only of the patched lines of course) and manually re-insert them. That did the trick for me.

So, thank you, dfrake, I bow before your genius!

menneke’s picture

On second thoughts, I discovered that -- even after the modifications -- there was still a line generated in the html head section which could cause problems with the search engines (too many 404's - and which I discovered thanks to the fantastic Xenu program mentioned above). This line was:
<link rel="alternate" type="application/rss+xml" title="RSS - The Title of the Node" href="node/150/feed" />
and it is generated in 'drupal_add_feed', which is called from half a dozen places.

So what I did, inspired by dfrake's patch, was disable the function 'drupal_add_feed' in common.inc altogether when the RSS checkbox (created by the third patch) was unset. In summary, I

  • kept the third patch (in system.module),
  • undid the two other patches (in common.inc and node.module) and
  • added the following code in common.inc in function 'drupal_add_feed':
  if (variable_get('feed_enabled', 1) != 1) {
    return $stored_feed_links;
  }

So, before:

function drupal_add_feed($url = NULL, $title = '') {
  static $stored_feed_links = array();

  if (!is_null($url)) {
   $stored_feed_links[$url] = theme('feed_icon', $url);

   drupal_add_link(array('rel' => 'alternate',
                         'type' => 'application/rss+xml',
                         'title' => $title,
                         'href' => $url));
  }
  return $stored_feed_links;
}

After:

function drupal_add_feed($url = NULL, $title = '') {
  static $stored_feed_links = array();

  if (variable_get('feed_enabled', 1) != 1) {
    return $stored_feed_links;
  }

  if (!is_null($url)) {
   $stored_feed_links[$url] = theme('feed_icon', $url);

   drupal_add_link(array('rel' => 'alternate',
                         'type' => 'application/rss+xml',
                         'title' => $title,
                         'href' => $url));
  }
  return $stored_feed_links;
}

For me it works, but these are my first endeavours in the php realm, so apply at your own risk. I'm doing this on a local development machine, not on a production website. I'll get back in a couple of days if it still turns out to hold well.

As in my previous post, all the credit goes to dfrake who provide the initial patch code and inspired me to dabble in php.

tumblingmug’s picture

In every (PHPTemplate) theme there is a file named page.tpl.php. Edit this file:

1.) Replace the line

<?php print $head ?>

with this:

<?php $headlines = explode("\n",$head);
	foreach ($headlines as $line) {
		if (strpos($line,'application/rss+xml') == 0)
			print $line ."\n";
	}
?>

This eliminates all RSS related feed links from the header over all pages of your site; if you want to remove only a distinct feed from your site, then change the string "application/rss+xml" into a unique string of the xml header output. So if you only want to disable the start page feed, you could use the string "rss.xml" for this. Or if you otherwise like all feeds disabled but not the start page (/node) so take the string "/feed".

2.) Remove this piece of code completely:

<?php print $feed_icons ?>

3.) Restrict direct URL access:

The feeds are created on direct URL access furthermore (as mentioned by others above). So you have to restrict the direct URL feed access also (best done probably by Apache directives). It could be done by changing the Drupal .htaccess file. if you're using clean URLs put these lines before the clean URL rewriting stuff:

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # RSS-Feed prohibited - this rule block first!
  # for home:
  RewriteCond %{REQUEST_FILENAME} ^rss.xml$ [OR]
  RewriteCond %{QUERY_STRING} ^q=rss.xml$ [OR]
  # for each other feed:
  RewriteCond %{REQUEST_URI} ^.*/feed$ [OR]
  RewriteCond %{QUERY_STRING} ^.*/feed$
  RewriteRule ^.*$ index.php?q=404 [L]

# clean URL rewriting stuff here

</IfModule>

Please note: even if you've enabled clean URLs, the feeds are accessible by the form www.example.com/?q=rss.xml also! Thats why each special feed here needs 2 conditions.
If you comment out some lines in the block (to provide only special feeds) make sure that the last condition does not end with "[OR]".

Done! I think, this is more convenient and more the drupal way than hacking core code.

So good luck!

MeanderingCode’s picture

The first block of code you suggested:

<?php $headlines = explode("\n",$head);
    foreach ($headlines as $line) {
        if (strpos($line,'application/rss+xml') == 0)
            print $line ."\n";
    }
?>

does something funny in my 5.2 installation. It's probably quite relevant that i'm using zengine theme engine, editing page.zen.php, but my small understading doesn't reveal how this could affect the following:

That code causes the printing of the text "Array" in the corner of my page...here's my rendered page source (just relevant section)

<head>
  <title>Boxes | Some catchy slogan, perhaps?</title>
    Array<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link rel="shortcut icon" href="/files/favicon.jpg" type="image/x-icon" />

As compared to

<head>
  <title>Boxes | Some catchy slogan, perhaps?</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="alternate" type="application/rss+xml" title="Boxes RSS" href="http://boxes/rss.xml" />

<link rel="shortcut icon" href="/files/favicon.jpg" type="image/x-icon" />

Any ideas?
It does a really cool little slide from the very corner out into the page a bit as the page renders, but i don't want it there, anyway.
Any help appreciated.

Cheers,
Sean

==================
"Not all who wander are lost."
-- J.R.R. Tolkien

Coupon Code Swap’s picture

There really should be a button to turn of syndication in Administer > Content management > RSS publishing.

Perhaps in Drupal 6?

------------------------------------
Themebot - Drupal theme gallery and free web layouts

VM’s picture

Perhaps in Drupal 6?

Nope.

Perhaps in Drupal 7 is someone interested in such a feature writes and supplies a patch to do so.

Coupon Code Swap’s picture

Is this something that would be complex to write?

Mguel’s picture

Great, thanks a lot!

jkmickelson’s picture

Note To Core Developers: This should be already be included in the Drupal Core

I am using the simple combination of two techniques from above:
"Turn RSS off the simple way... - dfrake - July 23, 2007"
"On second thoughts, I - menneke - July 25, 2007"

in ./modules/system/system.admin.inc, after line 1433 "function system_rss_feeds_settings() {",

I added the following lines:

  $form['feed_enabled'] = array(
      '#type' => 'checkbox',
      '#title' => t('RSS Feed enabled'),
      '#default_value' => variable_get('feed_enabled', 1),
      '#tree' => FALSE,
      '#description' => t('Check here if you want the RSS Feed to be enabled.')
    );

in ./includes/common.inc, after line 163 "static $stored_feed_links = array();",

I added the following lines:


  if (variable_get('feed_enabled', 1) != 1) {
    return $stored_feed_links;
  }

Now, go to Administer -> Content management -> RSS publishing
Uncheck "RSS Feed enabled" and click "Save configuration"

RSS Feeds are now disabled for Drupal 6.4.

Note to Drupal Users: It has been stated that no new features are being added to Drupal 6, only bugs fixes and security patches. This certainly is a security issue for one site of mine, while also being a desired feature on other sites. Hopefully, someone can get this issue recognized a security issue and get it addressed with the Core group. Thank you.

VM’s picture

things of this nature that alter core should be filed as an issue against the latest version 7.x-dev and a patch created. If the patch is accepted it can be applied to both 7.x and 6.x and even 5.x

Though I believe you will need to create an admin ui setting for this so it can be turned on and off.

As a sidenote: IMHO this isn't a security issue. Security issues are related to XSS exploits and the like. I understand a desire to turn off this type of feature but not labeling it a security issue.

Coupon Code Swap’s picture

Agreed. There should definitely be an on off option for this under Content Management > RSS Publishing.

Manowar721’s picture

Drupal 6.9 ONLY!!!

I don't take any responsibility for any of these modifications, you apply them at your own risk!
Worked without any Problems for me.

These three individuals inspired my workaround:
Turn RSS off the simple way - dfrake - July 23, 2007 - 14:07
On second thoughts, I - menneke - July 25, 2007
Disable RSS - jkmickelson - September 8, 2008 - 17:00

Step_1) Insert in ./includes/common.inc, after line 163 'static $stored_feed_links = array();'

if (variable_get('feed_enabled', 1) != 1) {
     return $stored_feed_links;
}

Step_2) In ./includes/common.inc on line approx 186-189
Replace:

function drupal_get_feeds($delimiter = "\n") {
     $feeds = drupal_add_feed();
     return implode($feeds, $delimiter);
}

With:

function drupal_get_feeds($delimiter = "\n") {
     if (variable_get('feed_enabled', 1) != 1) {
          return;
     }
     $feeds = drupal_add_feed();
     return implode($feeds, $delimiter);
}

Step_3) Insert in ./modules/node/node.module on Line 1647, after the Line containing 'function node_feed($nids = FALSE, $channel = array()) {'
if (variable_get('feed_enabled', 1) != 0) {
Then on line approx 1728, after the line containing 'print $output;'
Replace
}
With
}}

Step_4) In ./modules/node/node.module on Line 1744, after the Line containing '$feed_url = url('rss.xml', array('absolute' => TRUE));'
Replace:
drupal_add_feed($feed_url, variable_get('site_name', 'Drupal') .' '. t('RSS'));
With:

if (variable_get('feed_enabled', 1) != 0) {
     drupal_add_feed($feed_url, variable_get('site_name', 'Drupal') .' '. t('RSS'));
}

Step_5) Insert in ./modules/system/system.admin.inc, after line 1433 'function system_rss_feeds_settings() {',

$form['feed_enabled'] = array(
     '#type' => 'checkbox',
     '#title' => t('RSS Feed enabled'),
     '#default_value' => variable_get('feed_enabled', 1),
     '#tree' => FALSE,
     '#description' => t('Check here if you want the RSS Feed to be enabled.')
);

Now, go to Administer -> Content management -> RSS publishing
Uncheck "RSS Feed enabled" and click "Save configuration"

RSS Feeds are now disabled for Drupal 6.9.

If I have left something out that you need help with, you may contact me => Message.

Hope this helps,
Manowar721

EdgarPE’s picture

in common.inc after this line:
function drupal_add_feed($url = NULL, $title = '') {

put this:
return array();

kevbroch’s picture

and html source.

/Kevin

NikLP’s picture

... aaaaand you're also hacking core, which is a total no-no basically.

Kineta Systems - Web Development in Nottingham

KeithDaniels’s picture

In Drupal 6 RC1, I just tried adding the line return array(); in common.inc like EdgarPE suggested and it seems to work fine. The rss icon went away and I could nof find the RSS link in URL line or in the html source while using Firefox, Opera or Konqueror. Perhaps only in Windows?

Thanks EdgarPE.....

Keith

pmichelazzo’s picture

I'm trying to create some consolidate RSS feed.

I have a site with "normal" posts and a blog to fast tips & tricks. How can I merge all posts (site and blog) on just one RSS? Any idea?

Thanks!
Paulino

NikLP’s picture

There are many rss aggregation modules for drupal.

Built in is "aggregator". Also: aggregator2, leech, simplefeed, and the new feedapi.

Each does something different, but feedapi is designed to pretty much replace most tasks you can accomplish in Drupal with RSS.

Kineta Systems - Web Development in Nottingham

pnlnl’s picture

You can use views.module to get the trick done: you mask the page using a view, delete the node feed argument, and voila no rss without changing a line of code.
but that does most of the job, there is still the yoursite.tld/rss.xml which can be accessed by simply typing the address, there are many ways to get around this, the easiest way is to use the path_redirect.module to make a permanent redirection from the rss.xml page to your frontpage, for example.
And you might want to use the robots.txt file to block search engines from trying to access the page.

This way, you have 'no rss' with 'no dirty hacks'.

Devis’s picture

Thank you, the best solution, I redirected to the official news page (not a rss)
I also added this on template.php (Drupal 6.2), as found elsewhere:

function themename_feed_icon($url) {
return '';
}

--
Italian drupaler

ar-jan’s picture

The code mentioned by Devis works, but it should be:

function YOURTHEME_feed_icon($url, $title) {
return '';
}

Otherwise it is not correct, and it will break Devel Module functionality (as seen here)

varver’s picture

I am using Drupal 5.7 and I resorted to this:

system.module: function system_rss_feeds_settings()

Just update the line that reads
'#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
to
'#options' => drupal_map_assoc(array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),

Note the added first value: zero

After that, go to Administer > Content management > RSS publishing and select the Number of items per feed: 0 option.

I haven't tried the other tips to hide the feed's icon, but killing the feed's content is what matters the most at this time...

Seriously thought, something permanent should be done. I agree having RSS as an option (disabled / enabled + settings) is the right way.

GreenLED’s picture

I have not tried this hack, but that looks like a genius way to do it, thanks!

» Respectfully, GreenLED
» Download Spybot

davidwhthomas’s picture

A contrib module could use hook_form_alter to add that '0' option, that would avoid hacking core altogether.

Leeteq’s picture

Ref. this issue:
"Add permissions to disable RSS feeds"
http://drupal.org/node/28337

.
--
( Evaluating the long-term route for Drupal 7.x via BackdropCMS at https://www.CMX.zone )

strategictech’s picture

I added the directive below to my .htaccess file to redirect the blog feed back to the blog…

RedirectMatch /blog/feed /?q=blog

Pros:
Takes effect immediately, easy to manage, you can redirect any feed to any page or all feeds to a specific page…
Cons:
Need write access to the server, Redirect does not show Clean URL, Not easy to troubleshoot if an unfamiliar admin needs to remove this setting…

I would only recommend this method if you are certain you will be able to effectivly document it so that there will be no issues disabling if the need should arise

jreashor’s picture

http://library.acquia.com/content/turning-or-hiding-rss-drupal-6

I'm just about to try this out, but I'm sure it will work.

Update: This eliminates all of the feeds, but does not remove the icons on the pages, or in the address bar.

phpdiva’s picture

There is now a module to disable RSS Permissions: http://drupal.org/project/rss_permissions

Shyamji123456’s picture

Search in page.tpl.php print $feed_icons; and change in to //print $feed_icons;
that it ....

dmdmdm’s picture

I tried all suggestions for removing rss feed from my web site but does not works :( why there is still this icon saying "subscribe to updates via RSS" i dont want it

asnair’s picture

There is a file named feed.png at /public_html/misc folder. Rename this file to back_up_feed.png. This will will cause the RSS icon to disappear from your pages!

In case you wish to restore the icon at a later stage, you can always rename back_up_feed.png to feed.png

Anand

VM’s picture

that doesn't remove the rss feed. Just the icon. The icon could have been hidden with css which also won't change the fact that there is indeed still a feed.

AshleeSP’s picture

This worked for me but I only needed to remove the link in the source code:

function ninetystrong_html_head_alter(&$head_elements) {
unset($head_elements['drupal_add_html_head_link:alternate:http://www.YOURSITENAME.com/rss.xml']);
}

batigolix’s picture