How can I create a dynamic robots.txt?

Hi!

I want my users to be able to choose whether they want their profile indexed on search engines or not. I know that this isn’t a guaranteed solution since some search engines may not follow my rules.

I searched a little but couldn’t find anything useful.

How can I do that?

First, robots.txt isn’t “rules” per se but more a “suggestion”
So yes, though most search engines like Google and Bing will adhere to the robots.txt that is no guarantee all search engines will.

How to go about it really depends on how you have things set up.
If every user’s profile is in it’s own folder you could add them to robots.txt that way.
That sounds like a maintenance nightmare. Though it could be automated I suppose

I’m guessing the easiest way would be to automate it (using a checkbox in each profile page?) that would have a meta “noindex” added to the individual profile page.

1 Like

Of course, thank you!

I already include a file in head tags called header.php, so I can add something like below to it.

if($privacy == 1) {
 // add noindex
}
1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.