怎么实现?
二级域名重写
要求是
1.www.site.com/ccc都重写到www.site.com/index.php/ccc2.ccc.site.com重写到ccc.site.com/index.php/ccc我如下写的 1实现了 但是2怎么都有问题。不知道怎么办 求助
<?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
二级域名重写
要求是
1.www.site.com/ccc都重写到www.site.com/index.php/ccc2.ccc.site.com重写到ccc.site.com/index.php/ccc我如下写的 1实现了 但是2怎么都有问题。不知道怎么办 求助
<?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
是对的 但是页面却偏偏只是主页的地址
这个到底是为什么啊?
但是我这样写却显示的却是主页的内容
<add input="{HTTP_HOST}" pattern="^(?!www)(.*)\.site\.com$" />
是index.php根据参数动态显示ccc这个栏目?还是网站上有index.php/ccc这个目录?
看到的效果是一样的嘛?
index.php?/ccc程序会根据这个地址加载ccc的内容
这两个地址是有区别的
但是看到的效果不同,那就有可能是php程序的问题,它可能直接去读取了重写前的原始URL。
不过这种可能性不大,你确定重写后的地址直接粘贴到地址栏就可以看到不同的效果?
这个服务器 上面与asp网站啊
没法只能用iis 想加个apache 然后转发 我又觉得两个服务器 有点麻烦 唉!
1.www.site.com/ccc都重写到www.site.com/index.php/ccc2.ccc.site.com重写到ccc.site.com/index.php/ccc意思说 www.site.com/ccc实际访问的是 www.site.com/index.php/ccc
ccc.site.com实际访问的是ccc.site.com/index.php/ccc