IIS 中的 URL 重写规则发生冲突?
我在 URL 重写规则中遇到问题。 我使用 UrlRewritingNet.UrlRewriter Dll 在 asp.net 网站中进行 Url 重写。 我使用的规则名称为“高级” &其他规则名称为 DefaultRule,用于任何用户个人资料页面(即任何用户的个人资料页面)。 当我输入用户名“AdvancedMachinesTools”时。
规则如下:-
<urlrewritingnet rewriteOnlyVirtualUrls="true" contextItemsPrefix="QueryString" defaultPage="Login" xmlns="http://www.urlrewriting.net/schemas/config/2006/07">
<rewrites>
<add name="advanced" virtualUrl="^~/advanced" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/advancedSearch.aspx" ignoreCase="true" />
<add name="DefaultRule" virtualUrl="^~/(.*)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/UserProfile.aspx?uname=$1" ignoreCase="true"/>
</rewrites>
</urlrewritingnet>
我收到错误消息“文件不存在”,我最后在 web.config 文件中编写了 DefaultRule。
我是怎么解决的...?
已编辑
示例 假设我的网站网址:www.abcd.com
1)对于高级规则,我写了这样的URL www.abcd.com/advanced
规则:
<add name="advanced" virtualUrl="^~/advanced" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/advancedSearch.aspx" ignoreCase="true" />
2) 用于默认用户规则 假设用户名:AdvancedEyecare 它使用默认规则
<add name="DefaultRule" virtualUrl="^~/(.*)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/UserProfile.aspx?uname=$1" ignoreCase="true"/>
I am getting problem in URL rewrite rules.
I am used UrlRewritingNet.UrlRewriter Dll for Url rewriting in asp.net website.
I used rules name as "Advanced"
& Other rule name as DefaultRule that is used for any user profile page(ie. any user's profile page).
When I entered username as "AdvancedMachinesTools".
That Rules as below:-
<urlrewritingnet rewriteOnlyVirtualUrls="true" contextItemsPrefix="QueryString" defaultPage="Login" xmlns="http://www.urlrewriting.net/schemas/config/2006/07">
<rewrites>
<add name="advanced" virtualUrl="^~/advanced" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/advancedSearch.aspx" ignoreCase="true" />
<add name="DefaultRule" virtualUrl="^~/(.*)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/UserProfile.aspx?uname=$1" ignoreCase="true"/>
</rewrites>
</urlrewritingnet>
I got error message "File does not exist" I wrote DefaultRule at last in web.config file.
How I resolved it...?
EDITED
Examples
Suppose that my website url: www.abcd.com
1) For advanced rule I wrote URL like this www.abcd.com/advanced
Rule:
<add name="advanced" virtualUrl="^~/advanced" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/advancedSearch.aspx" ignoreCase="true" />
2) for Default user rule
for suppose username: AdvancedEyecare it used default rule
<add name="DefaultRule" virtualUrl="^~/(.*)" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/UserProfile.aspx?uname=$1" ignoreCase="true"/>
When I enter url like http://www.abcd.com/AdvancedEyecare
Then I got error "File not exist" because Rule used 1 advanced rule not used user default rule. I want to call userrule instead of 1 advanced rule.
How can solve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在第一个模式的末尾放置
$
:这将仅匹配
/advanced
并将其重写为/advancedSearch.aspx< /code>:
您想要的另一个重写是
Put an
$
at the end of the first pattern:This will only match
/advanced
and rewrite it to/advancedSearch.aspx
:The other rewrite you want is
首先我会改变重写规则的顺序。
然而,为什么 OlewinskiGroup 会匹配到“(.*)/Group”呢?不存在斜线
At first I would change the order of the rewrite rules.
Nevertheless, why would OlewinskiGroup be matched into "(.*)/Group" ? There is no slash present