搞了一个多星期,今天二级域名总算正式可以使用了,回忆起来有以下几步:
2. 修改urlrewrite项目代码:① BaseModuleRewriter.cs 类 中"app.Request.Path" 替换成"app.Request.Url.AbsoluteUri " ② ModuleRewriter.cs 类中 " string lookFor = "^" + RewriterUtils.ResolveUrl(app.Context.Request.ApplicationPath, rules[i].LookFor) + "$" 改成 tring lookFor = "^" + rules[i].LookFor + "$" ";只取 "URLRewriter.dll" 加入现有项目bin目录中
3.配置服务器,建一新网站,主机头为空,目的为了使用泛域名;网站目录指向要使用二级域名的网站;
IIS站点属性 ->主目录 -> 配置 -> 插入通配符应用程序映射,文件指向2.0下"aspnet_isapi.dll",并在确认该文件前去掉勾。
4.配置web.config文件如下。
<?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionH\"and\"ler, URLRewriter" /> </configSections>
<RewriterConfig> <Rules> <!-- Rules for Blog Content Displayer --> <RewriterRule> <LookFor>http\://(.*)\.1718vip\.com/default\.aspx</LookFor> <SendTo>~/company/$1/</SendTo> </RewriterRule> <RewriterRule> <LookFor>http\://(.*)\.1718vip\.com/index\.html</LookFor> <SendTo>~/company/$1/</SendTo> </RewriterRule> <RewriterRule> <LookFor>http\://(.*)\.1718vip\.com/(\w+)\.asp</LookFor> <SendTo>~/company/$1/$2.asp</SendTo> </RewriterRule> <RewriterRule> <LookFor>http\://(.*)\.1718vip\.com/(\w+)\.asp\?(\w+)=(.+)</LookFor> <SendTo>~/company/$1/$2.asp?$3=$4</SendTo> </RewriterRule> <!--<RewriterRule> 正确 <LookFor>http\://(.*)\.1718vip\.com/(\w+)\.asp\?id=(\d+)</LookFor> <SendTo>~/company/$1/$2.asp?id=$3</SendTo> </RewriterRule> 正确--> </Rules> </RewriterConfig> <system.web> <customErrors mode="Off"/> <httpModules> <add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter" /> </httpModules> <compilation debug="false" defaultLanguage="c#" /> </system.web> </configuration>
至此,基本上完成。
注意:如果不成功,80%是正则表达式没写好。
|