M
M
Maxim2014-10-06 12:06:16
PHP
Maxim, 2014-10-06 12:06:16

How to dynamically create a robots.txt file for each subdomain?

The situation is this, the site is regionally divided into subdomains. There are a lot of them, and search bots need to give robots.txt and sitemap different for each subdomain. From here the question arises, how is it possible and is it possible at all to dynamically create robots.txt for the subdomain to which the bot entered, using a script when entering subdomain.site.ru/robots.txt?
Now robots.txt and sitemap are in the root of the www.site.ru site directory and are accordingly shown for all other subdomains, I would like to change this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
KorsaR-ZN, 2014-10-06
@go3l337

Yes, via mod_rewrite (for apache), create an alias for /robots.txt leading either to a pre-generated file for a specific domain, or to a php script that generates it on the fly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question