首頁  >  文章  >  後端開發  >  iis7 用url write 模块实现泛解析 二级域名重写?该如何处理

iis7 用url write 模块实现泛解析 二级域名重写?该如何处理

WBOY
WBOY原創
2016-06-13 13:40:421015瀏覽

iis7 用url write 模块实现泛解析 二级域名重写??
怎么实现?
二级域名重写
要求是 
1.www.site.com/ccc都重写到www.site.com/index.php/ccc

2.ccc.site.com重写到ccc.site.com/index.php/ccc

我如下写的 1实现了 但是2怎么都有问题。不知道怎么办 求助

XML code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webserver>
        <rewrite>
            <rules>
                <clear></clear>
                <rule name="重写规则1 对于 域名泛解析" stopprocessing="true">
                    <match url=".*"></match>
                    <conditions logicalgrouping="MatchAll" trackallcaptures="false">
                        <add input="{REQUEST_FILENAME}" matchtype="IsFile" negate="true"></add>
                        <add input="{HTTP_HOST}" pattern="([^.www]+)\.site\.com"></add>
                    </conditions>
                    <action type="Rewrite" url="index.php/{C:1}" appendquerystring="true" logrewrittenurl="true"></action>
                </rule>
                <rule name="Imported Rule 1">
                    <match url="(.*)$" ignorecase="false"></match>
                    <conditions logicalgrouping="MatchAny" trackallcaptures="false">
                        <add input="{REQUEST_FILENAME}" matchtype="IsFile" negate="true"></add>
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:1}" appendquerystring="true" logrewrittenurl="true"></action>
                </rule>
            </rules>
            <rewritemaps>
                <rewritemap name="域名泛解析"></rewritemap>
            </rewritemaps>
        </rewrite>
        <caching>
            <profiles>
                <remove extension=".html"></remove>
                <add extension=".html" policy="DisableCache" kernelcachepolicy="DontCache" duration="00:00:30"></add>
            </profiles>
        </caching>
    </system.webserver></configuration>


------解决方案--------------------
ccc.site.com 重写成 index.php/ccc,就是显示index.php这个页面吧,有什么不对的地方?
------解决方案--------------------
正则好像不太正确,改成这样好些,不过你那样写也能通过:
 
------解决方案--------------------
ccc这个栏目怎么在index.php下面?不懂。。。
是index.php根据参数动态显示ccc这个栏目?还是网站上有index.php/ccc这个目录?
------解决方案--------------------
那你暂时禁用rewrite,直接输入:ccc.site.com/index.php/ccc
看到的效果是一样的嘛?
------解决方案--------------------
如果你确定直接输入的地址和重写地址一样,都是:ccc.site.com/index.php/ccc
但是看到的效果不同,那就有可能是php程序的问题,它可能直接去读取了重写前的原始URL。
不过这种可能性不大,你确定重写后的地址直接粘贴到地址栏就可以看到不同的效果?

------解决方案--------------------
你的泛解析规则和针对www.site.com的规则看上去很容易混淆,你先把“Imported Rule 1”去掉试试
------解决方案--------------------
url重写不会改变浏览器地址栏的内容

看了半天,也没有看到你的需求是什么,只看到了 PATH_INFO
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn