Setting robots meta tag to content=”noindex, follow” to any page in Joomla 1.5.
I have a client with a shop made in Joomla 1.5 that didn’t wanted to upgrade to Joomla 2.5 so I searched for a custom code to have a little control over the robots meta tag.
There is absolutely no plugin that can do this in Joomla 1.5 so this information is gold!
Go to /public_html/libraries/joomla/document/html and edit html.php
replace:
//set default document metadata
$this->setMetaData(‘Content-Type’, $this->_mime . ‘; charset=’ . $this->_charset , true );
$this->setMetaData(‘robots’, ‘index, follow’ );
with:
//set default document metadata
$this->setMetaData(‘Content-Type’, $this->_mime . ‘; charset=’ . $this->_charset , true );
$queryString = $_SERVER[‘REQUEST_URI’];
if (( $queryString == ” ) || ( $queryString == ‘/National-news’ ) || ( $queryString == ‘/Business’ ) || ( $queryString == ‘index.php/Sport’ ) || ( substr($queryString, -5 ) == ‘.html’ )) {
$this->setMetaData(‘robots’, ‘index, follow’ );
}else {
$this->setMetaData(‘robots’, ‘noindex, follow’ );
}
Just replace “/National-news” with your pages that you want to have the robots content=”index, follow” and the rest of the pages will be content=”noindex, follow”. There must be a “/” before any page link.
This is very useful for any SEO expert so please be kind and share it.
Original source: http://stackoverflow.com/questions/6014008/joomla-noindex-follow-php-code/6042875#6042875