一页两个XML网站地图rewrited在.htaccess [英] Two XML sitemaps for one page rewrited in .htaccess

查看:187
本文介绍了一页两个XML网站地图rewrited在.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了两个站点地图文件在同一页:

I have created two sitemap files for the same page:


  • sitemap_en.xml

  • sitemap_sk.xml

同一页面正在两个领域。

Same page is working on two domains.


  • 域1 - 为SK语言

  • DOMAIN2 - 为EN语言

我需要建立以下在.htaccess重写规则:

I need to create following rewrite rule in .htaccess:


  • 如果domain1.sk/sitemap.xml返回sitemap_sk.xml

  • 如果domain2.com/sitemap.xml返回sitemap_en.xml

推荐答案

您可以使用以下条件规则htaccess的:

You can use the following conditional rules in htaccess :

RewriteEngine on

##1)if host=="www.domain1.sk##
RewriteCond %{HTTP_HOST} ^(www\.)?domain1\.sk$
##rewrite "/sitemap.xml" to "/sitemap_sk.xml"##
RewriteRule ^/?sitemap\.xml$ /sitemap_sk.xml [NC,L]
##2)if host=="www.domain2.com##
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com$
##rewrite "/sitemap.xml" to "/sitemap_en.xml"##
RewriteRule ^/?sitemap\.xml$ /sitemap_en.xml [NC,L]


  • 第一条规则将改写 /sitemap.xml /sitemap_sk.xml 如果主机值为 www.domain1.sk domain1.sk

    2#规则将重写 /sitemap.xml /sitemap_en.xml 如果主机值为 www.domain.com domain.com

    The #2 rule will rewrite /sitemap.xml to /sitemap_en.xml if the host value is www.domain.com or domain.com .

    这篇关于一页两个XML网站地图rewrited在.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆