set "noindex" for URLs containing "mact"

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
User avatar
creopard
Forum Members
Forum Members
Posts: 47
Joined: Fri Nov 10, 2017 10:25 am
Location: .de
Contact:

set "noindex" for URLs containing "mact"

Post by creopard »

Dear community,

having installed the News and CGBlog Module, I have plenty of URLs like:

Code: Select all

.../index.php?mact=CGBlog,me9d1a,default,1&me9d1apagelimit=10&me9d1apagenumber=6&me9d1areturnid=1&page=1
Since Google Webmastertools keeps complaining about "sites with same content", I decided to set a "noindex" for these kind of pages with an UDT:

Code: Select all

//UDT CODE for "noindex_on_mact_urls"
if (substr($_SERVER['QUERY_STRING'], 0, 5 ) === "mact="){
$noindexurl = 'true';
$smarty->assign('noindexurl', $noindexurl);
}
I'm calling this UDT {noindex_on_mact_urls} in the header section before the {metadata} tag.
In the global settings -> global metadata, I've inserted this snippet:

Code: Select all

{if ((isset($noindexurl) && $noindexurl =='true'))}
{*via UDT "noindex_on_mact_urls"*}
<meta name="robots" content="noindex, follow">
{else}
<meta name="robots" content="index, follow">
{/if}
So all URLs starting with "mact=" won't be indexed by Google any more :)

This approach works quite well, but is there a more elegant way to do this?
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1621
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: set "noindex" for URLs containing "mact"

Post by DIGI3 »

You can omit url parameters directly within Google's console.
Not getting the answer you need? CMSMS support options
User avatar
creopard
Forum Members
Forum Members
Posts: 47
Joined: Fri Nov 10, 2017 10:25 am
Location: .de
Contact:

Re: set "noindex" for URLs containing "mact"

Post by creopard »

Good point, but I guess that will only help before Google is aware of the URLs.
I've read elsewhere:
“The URL parameter handling tool would not remove URLs from the search results. It’s really only to refine the crawling of URLs.

So it’s not something where we would say you add this parameter to that tool and then suddenly all those pages disappear from search results.

It’s more that, over time, we would crawl those URLs less and over time they would drop out from the search results but it wouldn’t be any immediate change there.”
Starting at 46:44
https://www.youtube.com/watch?v=5w4iFGxrqjY
Post Reply

Return to “Developers Discussion”