Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
1.2k views
in Q2A Core by
Does anyone know the best way to set meta noindex or nofollow values for bots, Googlbot on select pages? Of course I want questions pages to be indexed, but I don't want search bots to index tags, login pages, register, and some others too. I could try via robots.txt file, but using META value seems like the best approach. Perhaps a PHP "if, then" URL conditional statement might work dynamically in the head? If url contains "login, register, tags", then meta value for bot=noindex

Any ideas? Thanks!
Q2A version: 1.5.2

3 Answers

–1 vote
by
use "robots.txt" instead of Meta tags. read more here:

http://www.question2answer.org/qa/15314/robots-txt-for-q2a-best-practices

here is the one I used with wordpress:

http://askweb.ir/robots.txt
by
robots.txt is for crawl/don't crawl only. Meta Tags in <head> will decide, whether to index or noindex
+1 vote
by
I found a way. Testing, it works fine, but I haven't figured out how to do a * wildcard for example after /qa/login* . Ufortunately, it's not as simple as adding the *. Anyway, I added to the custom theme qa-theme.php functions:

        function head_metas()
        {
            if ($_SERVER['REQUEST_URI'] == '/qa/login') $this->output('<meta name="robots" content="noindex, follow">');
            if ($_SERVER['REQUEST_URI'] == '/qa/register') $this->output('<meta name="robots" content="noindex, follow">');
            if ($_SERVER['REQUEST_URI'] == '/qa/admin') $this->output('<meta name="robots" content="noindex, follow">');
            qa_html_theme_base::head_metas();
        }
by
Hello. Thank you for this tip.
And what about URL like this - http://mysite.com/qa/user/Nickname?
I tryed
if ($_SERVER['REQUEST_URI'] == '/qa/user') $this->output('<meta name="robots" content="noindex, follow">');
but not work!

And how ad meta for this URL http://mysite>com/qa/register?to=ask ?
0 votes
by
Hey, guys. Any idea for my problem?
...