我爱帮助网--QQ交流群号

Nas交流与矿渣群(unraid 群晖 猫盘 蜗牛等):372167400         物联网/智能家居群:518812757             帮助教程:手册大全

软件使用与建站群:1057308983      虚拟化交流群:13448651

蝉知与米拓共存时sitemap有冲突的解决办法

2017-04-06 23:02:00
zstmtony
原创
2839

本人是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 ,则上面也对应做相应的修改

    

最终可完全实现 所要的功能

   

0
发表评论
评论通过审核后显示。
联系我们
联系人: 王先生