积极答复者
伪静态后的参数传递

问题
-
您好!我想请教一个问题。
我用asp.net实现伪静态
我的正则表达式是:<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/Default\.html</LookFor><SendTo>~/Default.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/.*\.html</LookFor><SendTo>~/ProductShow.aspx?ID=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>我输入http://localhost:1309/FeiWeb/Default.html 能正常的访问和http://localhost:1309/FeiWeb/Default.aspx一样的效果
但是在访问http://localhost:1309/FeiWeb/ugg004.html的时候却不行了因为request.Querystring(ID)=“$1”而不是request.Querystring(ID)="ugg004",这个地址对应的真实地址ProductShow.aspx?ID=ugg004
请问这是什么原因呢
答案
-
<LookFor>~/.*\.html</LookFor>
你加个括号试试
<LookFor>~/(.*)\.html</LookFor>
- 已标记为答案 BoberSongModerator 2010年9月10日 7:33
-
为了避免这种情况,建议全站所有链接,使用绝对路径,包括CSS文件、图片、JS文件等等。
- 已标记为答案 BoberSongModerator 2010年9月10日 7:33
全部回复
-
<LookFor>~/.*\.html</LookFor>
你加个括号试试
<LookFor>~/(.*)\.html</LookFor>
- 已标记为答案 BoberSongModerator 2010年9月10日 7:33
-
您好,我现在想加个目录 就是
<lookFor>~/Product/(.*)\.html</lookFor>
<SendTo>~/ProductShow.aspx?ID=$1</SendTo>
这样当我进入产品页productshow.aspx的时候,图片都不显示了。头部的超级链接路径也变了,
本来是http://localhost:1309/FeiWeb/login.aspx 变成了http://localhost:1309/FeiWeb/Product/login.aspx
但是我想加Product这个目录,请问这种情况要怎么处理呢
- 已编辑 randy orten 2010年9月4日 14:02 原来的问题描述不好
-
为了避免这种情况,建议全站所有链接,使用绝对路径,包括CSS文件、图片、JS文件等等。
- 已标记为答案 BoberSongModerator 2010年9月10日 7:33