我不想把二级域名写死在web.config中,而且我要重写的目标url也不能写死
比如:
http://localhost/mdcn.cn/page?name=wutai 这是完整地址
重写:wutai.mdcn.cn/wutai.aspx(html)
如果name=""改变了的话,前面的重写的"".mdcn.cn/"".aspx也要改变.
也就是说这个name的名字在里面不能固定,我在看你在.dll文件改的代码,也就把它写死了呀.if (re.IsMatch(requestedPath))
{
//找到url里的二级域名
string [] UserHost = app.Request.Url.Host.Split ( new Char [] { '.' } );
string domain2=UserHost [0];
//根据需要设定要重写的目标url
string sendToUrl ;
if(domain2==” Love”)
sendToUrl =” /action.aspx?id=1”;
else if(domain2==” call”)
sendToUrl =” /action.aspx?id=2”;
else i f(domain2==” walkwith”)
sendToUrl =” /walk.aspx”;
RewriterUtils.RewriteUrl(app.Context,sendToUrl);
}
因为以上name是从数据库读取出来的,对应的信息是单独网面的名字,如果要增加页面的话,那还要在.dll文件里改呀,这太麻烦了.可不可教我一下怎么实现这个功能.