K
K
kimqar342534262021-06-03 09:18:55
PHP
kimqar34253426, 2021-06-03 09:18:55

Is it possible to make two different Sitemaps for different domains but with the same root directory?

There are two domains that refer to the same folder.
For example site1.ru and site2.ru,
now the sitemap contains locs of the form site1.ru....
How to make it so that if you go to site2.ru/sitemap.xml, then the domain url in locs is site2.ru.. , and for site1.ru it is similar to site1.tu...?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mafia8, 2021-06-03
@kimqar34253426

.htaccess file

RewriteEngine On
RewriteBase /

RewriteRule sitemap.xml sitemap.php

Sitemap.php file
$host=$_SERVER['HTTP_HOST'];
if($host=='site1.ru') echo file_get_contents('sitemap_xml_site1_ru.xml');
if($host=='site2.ru') echo file_get_contents('sitemap_xml_site2_ru.xml');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question