我的主页可以通过2个不同的域访问。
1: https://example.at
2:https://example.de
我为每个站点手动创建了站点地图.xml该站点地图位于页面的根目录中。(网站地图1.xml/网站地图2.xml)
输入 URLexample.at/sitemap.xml或example.de/sitemap.xml后,我需要重定向到正确的.xml文件。
1:https://example.at/sitemap.xml => https://example.at/sitemap1.xml
2:https://example.de/sitemap.xml => https://example.de/sitemap2.xml
我尝试了以下重定向规则:
RewriteCond %{REQUEST_URI} ^/sitemap.xml$
RewriteRule .* https://example.at/sitemap1.xml [R=301,L]
RewriteCond %{REQUEST_URI} ^/sitemap.xml$
RewriteRule .* https://example.de/sitemap2.xml [R=301,L]
无论我输入.de地址还是.at地址,我都会被转发到:https://example.at/sitemap1.xml。
我没有重写规则的经验,所以我使用了: https://www.webcellent.com/tools/modrewrite/
将不胜感激任何帮助。
提前感谢!
RewriteCond %{HTTP_HOST} ^example.at$
RewriteCond %{REQUEST_URI} /sitemap.xml
RewriteRule ^(.*)$ https://example.at/sitemap1.xml [R=301,L]
RewriteCond %{HTTP_HOST} ^example.de$
RewriteCond %{REQUEST_URI} /sitemap.xml
RewriteRule ^(.*)$ https://example.de/sitemap2.xml [R=301,L]
编辑:可能是缓存问题