蝉知与米拓共存时sitemap有冲突的解决办法
- 2017-04-06 23:02:00
- zstmtony 原创
- 3155
本人是PHP初学者。纯粹是暴力方法,如果大家有更好的代码,请分享,谢谢
特别感谢 蝉知-技术-实习(2276262152) 的帮助
目的:为解决2个网站系统 共存时,网站地图的冲突问题
蝉知(ChanZhi)和米拓(metinfo)都使用了 http://www.域名.com/sitemap 作为网站地图
思路:2者虽然在伪静态是地址相同,但实际指向不同,所以可以用伪静态 转向来实现,但需要解决网站本身 显示的链接
1.设置网址为伪静态 PATH_INFO
2.修改 system\framework\helper.class 这个文件的函数 static public function createLink
在最后的返回代码 return $link; 前添加2句代码:
if($link === '/sitemap/') $link = '/sitemapcz/';
if($link === '/sitemap.xml') $link = '/sitemapcz.xml';
3. 修改Web.config 添加这些规则
<rule name="ChanZhiSitemap" stopProcessing="true">
<match url="^(sitemapcz\/?)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/index.php/sitemap" />
</rule>
<rule name="ChanZhiSitemap.xml" stopProcessing="true">
<match url="^(sitemapcz.xml)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/index.php/sitemap.xml" />
</rule>
如 index.php 改为了 indexcz.php ,则上面也对应做相应的修改
最终可完全实现 所要的功能
联系人: | 王先生 |
---|