K
K
kalkoolesya2020-02-01 09:57:30
URL Handling
kalkoolesya, 2020-02-01 09:57:30

How to redirect to subdomains correctly?

I am developing an online store, I need to make redirects from the main domain to subdomains depending on the geo. Okay, how I imagine it:
In order not to bother, now let's look at an example of how to redirect from one domain to one subdomain. Make a 302 redirect on the main domain:

RewriteEngine On
RewriteCond %{HTTP_HOST} my.site
RewriteRule (.*) https://1.my.site/$1 [R=302,L]

And in the robots.txt file of the subdomain I write:
User-agent: *
Host: my.site
Disallow: *

This is to prevent subdomains from being indexed.
Or another option:
User-agent: *
Host: my.site
Sitemap: http://1.my.site/sitemap.xml

But this sitemap will contain links like my.site , that is, the main domain.
From all the above, a few questions:
1) Which of the last options is more correct?
2) Since my task is to index only the main domain, but it constantly redirects itself, will this create problems for the indexing itself? How can this be avoided?
3) Maybe I wrote the wrong way, share your ideas.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question