0

I have a website. But when someone enters at root level. I want them to choose between

Button 1 "www.website.com"

and

Button 2 "subdomain.website.com"

I was thinking about using the PHP $SESSION variable to do this.

  • But my question is, will the search engine robots make a button choice and crawl both websites? Or do I block them when asking to chose one of two buttons?

Thanks

Marcus Silverman
  • 243
  • 1
  • 7
  • 22
  • I this option 1 is a perfect and easy to remember. use `htaccess` to redirect users from a sub domain to the actual domain. and also prevent bots from indexing your subdomain. may be that is a solution –  Nov 09 '19 at 07:15
  • Thanks, but I want the bots to crawl both the subdomain, and the main domain. – Marcus Silverman Nov 09 '19 at 07:27
  • The bots will organically crawl any and all links. Helps to also have the robots.txt and sitemap.xml files. Depends on the specific bot performing the crawling as well. Bots may not be able to use a session state What purpose is the `$_SESSION` expected to serve? – Will B. Nov 09 '19 at 07:41
  • Thanks, the $_SESSION is to display a prompt if they haven't already chosen button 1 (domain) or button 2 (subdomain). Is there a better way? Thanks – Marcus Silverman Nov 09 '19 at 07:46
  • @MarcusSilverman first create a `sitemap.xml` for site 1 and site 2, then create a `robots.txt` and add it to site 1, in the `robots.txt` specify and add the `sitemap.xml` files for both sites. search bot will come and index the sitemap details for all sites –  Nov 09 '19 at 07:57
  • Since you would register both the main domain, and subdomain sites on your desired search engine(s), the issue is rather moot, since the bot(s) would crawl both, A 307 redirect based on the session should be fine, but the issue would be what your main domain index page appears as to the bots. Because of this I would direct the bots to the main domain index page outright, to avoid false hits from the bots and not have the decision page displayed at all on search indexes, since it would negatively affect SEO.. – Will B. Nov 09 '19 at 08:01
  • Thanks @fyrye, how would I redirect the bots to the main index page, to bypass the session? – Marcus Silverman Nov 09 '19 at 08:06
  • See: [redirect all bots using htaccess apache](https://stackoverflow.com/q/2691956/1144627) you can also specify it in robots.txt but robots.txt can be ignored by some crawlers. Don't block and redirect. Choose one. – Will B. Nov 09 '19 at 08:07
  • Thanks all, but one question remains. If I don NOT do any changes, but there has to be a valid $_SESSION to see the sites. Would that stop the bots? – Marcus Silverman Nov 09 '19 at 09:53
  • 1
    This question appears to be off-topic because it is about **SEO** which is off-topic at Stack Overflow. Please read ["Which SEO questions should be closed as non-programming/non-admin?"](//meta.stackoverflow.com/a/382618) to better understand when SEO questions are acceptable to ask here (most are not) and where you might be able to get assistance. – John Conde Nov 09 '19 at 12:28
  • Ok John, thanks. My intention was not to "improve" my SEO, but rather get an understanding of how the robots technically interpret the page.Thanks anyway everybody. – Marcus Silverman Nov 10 '19 at 09:49
  • 1
    Regarding bots and `$_SESSION`, the answer is yes it would break them, Generally speaking, pretty much all search engine spiders will ignore cookies and therefor do not support session ids. So having a requirement of a session would break organic crawling. You would need to setup [cloaking rules](https://support.google.com/webmasters/answer/66355?hl=en), to allow the spiders access to certain areas to properly index your site(s) without a session id. – Will B. Nov 10 '19 at 19:03
  • 1
    To elaborate on the comment from John, anything related to bots is typically to address SEO. While your question is not about "improving" SEO specifically. It does relate to "how search engines index your site(s)". So your question specifically is not an appropriate topic for StackOverflow, which is intended for computer programming related questions. To which you would receive much more informed help from the [Webmasters.Stack Exchange](https://webmasters.stackexchange.com/) – Will B. Nov 10 '19 at 19:25

0 Answers0