日期:2014-05-17  浏览次数:20564 次

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


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="重写规则1 对于 域名泛解析" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{HTTP_HOST}" pattern="([^.www]+)\.site\.com" />
                    </conditions>
                    <action type="Rewrite" url="index.php/{C:1}" appendQueryString="true" logRewrittenUrl="true" />
                </rule>
                <rule name="Imported Rule 1">
                    <match url="(.*)$" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" logRewrittenUrl="true" />
                </rule>
            </rules>
            <rewriteMaps>
                <rewriteMap name="域名泛解析" />
            </rewriteMaps>
        </rewrite>
        <caching>
            <profiles>
                <remove extension=".html" />
                <add extension=".html" policy="DisableCache" kernelCachePolicy="DontCache" duration="00:00:30" />
            </profiles>
        </caching>
    </system.webSer



------解决方案--------------------
ccc.site.com 重写成 index.php/ccc,就是显示index.php这个页面吧,有什么不对的地方?
------解决方案--------------------
正则好像不太正确,改成这样好些,不过你那样写也能通过:
 <add input="{HTTP_HOST}" pattern="^(?!www)(.*)\.site\.com$" />
------解决方案--------------------
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