If this is your first visit, check our documentation. To post, register or login.
Forums / Business Issues / Search Engines / SEMRush user agent in spiders.txt, login returns 302 leading to annoying ranking

SEMRush user agent in spiders.txt, login returns 302 leading to annoying ranking

Started by neekfenwick on 28 Jun 2020, 11:55 AM · Views: 91

Results 1 to 7 of 7
28 Jun 2020, 11:55 AM
#1
neekfenwick avatar

neekfenwick

New Zenner

Join Date:
Feb 2009
Posts:
101
Plugin Contributions:
0

SEMRush user agent in spiders.txt, login returns 302 leading to annoying ranking

Hi! I'm not sure what changed and where, but suddenly SEMRush sent us a notice that every page on our site contained a link that returned a 302 response. It was a bit of a weird thing to complain about, not exactly the end of the world, but the reason is that every page has our 'login' link on it, and when they crawl the site they send every request with a User-Agent string that's listed in our spiders.txt file.

So init_sessions.php goes into the SESSION_BLOCK_SPIDERS == 'True' block, checks the spiders list, and because it finds it, does not start the session. We get $spider_flag=true and $session_started=false.

Then when the link being accessed is the login page, includes/modules/pages/login/header_php.php says that if $session_started==false, then redirect to FILENAME_COOKIE_USAGE. This is what's causing the negative ranking in SEMRush's report, they don't like any kind of 302 redirect.

I can see why the various parties in this engagement do what they do, but all my options seem poor at this point:

  • I would not want to remove SEMRush from spiders.txt, because I don't want their crawling to appear in our access stats etc as a user visit (see counter.php).
  • I wouldn't want to hack init_sessions.php to 'allow' the SEMRush user agent to start the session, because it's ugly as hell.
  • I can manually 'hide' the warnings on SEMRush but that's laborious for our > 160 pages.

I doubt very much that complaining to SEMRush would get anywhere because they pretty much have to pass a user agent that mentions them, so any action on their part doesn't seem warranted to me.

My best bet right now seems to be option 2 of the 3 above, so I've added a very hacky modification to init_sessions.php:

  if ($spider_flag == false
      /* New bit here */ || strpos(strtolower($user_agent), 'semrush') !== FALSE) {
    zen_session_start();
    $session_started = true;
  }

So the new logic I'm imposing is, although normally any site visit by a spider sets $spider_flag=true and $session_started=false, in the special case of web crawlers who are ranking us on the behaviour of the site that depends on a session existing, actually start a session and allow $spider_flag=true and $session_started=true.

Of course I shouldn't hardcode 'semrush' in the code, this is just a first step in working through this problem.

Any feedback welcome :)

28 Jun 2020, 12:15 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: SEMRush user agent in spiders.txt, login returns 302 leading to annoying ranking

Why are they ignoring the nofollow, noindex associated with the login screen or is this a situation where they don't know not to do that until they arrive and the undesirable 302 is identified first?

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

28 Jun 2020, 3:18 PM
#3
neekfenwick avatar

neekfenwick

New Zenner

Join Date:
Feb 2009
Posts:
101
Plugin Contributions:
0

Re: SEMRush user agent in spiders.txt, login returns 302 leading to annoying ranking

mc12345678:

Why are they ignoring the nofollow, noindex associated with the login screen or is this a situation where they don't know not to do that until they arrive and the undesirable 302 is identified first?

Very interesting point. I coded our tpl_header myself with the login link in it, and am not immediately familiar with nofollow, noindex.. wouldn't they be attributes on the anchor tag that leads to the login page? In which case, I may have shot myself in the foot and not included them, though I think that particular line of code was retained from a very old and perhaps canon file from ZC. Or, is this a meta tag that should exist on the login page? I'll look into this tomorrow (gone 10pm here now). URL is premierrange dot co dot uk FYI.

29 Jun 2020, 4:27 AM
#4
neekfenwick avatar

neekfenwick

New Zenner

Join Date:
Feb 2009
Posts:
101
Plugin Contributions:
0

Re: SEMRush user agent in spiders.txt, login returns 302 leading to annoying ranking

Man, placating SEO checker tools can be a real chore. I added rel="nofollow" to the anchor tags that led to the login page, and re-ran the SEO audit on SEMRush, and they didn't like it. Just for reference here's the new warning they issued:

347 outgoing internal links contain nofollow attribute

The rel="nofollow" attribute is an element in an <a> tag that tells crawlers not to follow the link (e.g., "<a href="http://example.com/link" rel="nofollow">Nofollow link example</a>")."Nofollow" links don’t pass any link juice to referred webpages. That’s why it is not recommended that you use nofollow attributes in internal links. You should let link juice flow freely throughout your website. Moreover, unintentional use of nofollow attributes may result in your webpage being ignored by search engine crawlers even if it contains a valuable content.

HOW TO FIX IT

Make sure not to use nofollow attributes by mistake. Remove them from <a> tags, if necessary.

So, meh. I don't have the energy to debate the decisions that SEO tools like SEMRush make, I'll just say I don't agree with it. What did seem to "work" was the following line in robots.txt:

Noindex: /index.php?main_page=login

This has cleared up all the warnings that I reported so, thanks @mc12345678, your comment led me in a good direction.

29 Jun 2020, 11:43 AM
#5
mprough avatar

mprough

Totally Zenned

Join Date:
Nov 2007
Location:
Woodbine, Georgia, United States
Posts:
4,336
Plugin Contributions:
41

Re: SEMRush user agent in spiders.txt, login returns 302 leading to annoying ranking

They are saying not to nofollow your own pages. So change your tag from

<meta name="robots" content="noindex, nofollow">

to

<meta name="robots" content="noindex>

~Melanie

29 Jun 2020, 9:08 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: SEMRush user agent in spiders.txt, login returns 302 leading to annoying ranking

mprough:

They are saying not to nofollow your own pages. So change your tag from

<meta name="robots" content="noindex, nofollow"> ``` > > to > > ``` <meta name="robots" content="noindex> ``` > > ~Melanie If you've manually added those tags yourself to custom pages, yes, then consider removing/changing them. But don't change what Zen Cart is generating by default for those tags, unless you understand all the implications of the change, and all the pages that are affected by doing so.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

2 Jul 2020, 3:22 AM
#7
neekfenwick avatar

neekfenwick

New Zenner

Join Date:
Feb 2009
Posts:
101
Plugin Contributions:
0

Re: SEMRush user agent in spiders.txt, login returns 302 leading to annoying ranking

mprough:

They are saying not to nofollow your own pages. So change your tag from

<meta name="robots" content="noindex, nofollow"> ``` > > to > > ``` <meta name="robots" content="noindex> ``` > > ~Melanie

Thanks Melanie, however I didn't change anything in my meta tags. I presume you mean on the login page itself, which isn't actually reached in my case, it returns a 302 redirect because of the behaviour I mentioned above (the session not being started in login/header_php.php).. or if you mean site-wide then having a nofollow meta tag would result in all links on the page being considered 'nofollow', if I understand how it works, which would be rather crazy :)

What I had done, in an attempt to fix the original problem in this post, was add rel="nofollow" to the anchor tag that leads to the login page .. so that is, on every page in the header content, there was then <a href="path-to-login" rel="nofollow"> .. SEMRush then complained about that. Eventually, a fairly clean solution was to add a rule to robots.txt, so no actual page content needed changing to sort out my original problem.