再发一贴,如何使用正则表达式,对url进行重写(urlRewrite)?
除了以下文件夹之外:
template
images
admin
css
js
其它文件夹都要进行重写,应该怎么做?我像下面这样写是不行的。
<RewriterRule>
<LookFor>~/(.*?)/(.*?)</LookFor>
<SendTo>~/CommPages/$2?Item=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/admin/</LookFor>
<SendTo>~/admin/</SendTo>
</RewriterRule>想了想,用排除的方法,
<RewriterRule>
<LookFor>~/^(?!admin|images)/(.*?)</LookFor>
<SendTo>~/CommPages/$2?Item=$1</SendTo>
</RewriterRule>即是当文件夹不是admin或images时,则重定向到:CommPages/$2?Item=$1。
不过这个正则表达式好像是错的。但是,像下面这样,只拿其中一个来试验也不行。
<RewriterRule>
<LookFor>~/^(?!admin)/(.*?)</LookFor>
<SendTo>~/CommPages/$2?Item=$1</SendTo>
</RewriterRule>
除了以下文件夹之外:
template
images
admin
css
js
其它文件夹都要进行重写,应该怎么做?我像下面这样写是不行的。
<RewriterRule>
<LookFor>~/(.*?)/(.*?)</LookFor>
<SendTo>~/CommPages/$2?Item=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/admin/</LookFor>
<SendTo>~/admin/</SendTo>
</RewriterRule>想了想,用排除的方法,
<RewriterRule>
<LookFor>~/^(?!admin|images)/(.*?)</LookFor>
<SendTo>~/CommPages/$2?Item=$1</SendTo>
</RewriterRule>即是当文件夹不是admin或images时,则重定向到:CommPages/$2?Item=$1。
不过这个正则表达式好像是错的。但是,像下面这样,只拿其中一个来试验也不行。
<RewriterRule>
<LookFor>~/^(?!admin)/(.*?)</LookFor>
<SendTo>~/CommPages/$2?Item=$1</SendTo>
</RewriterRule>
......没明白你使用的是什么工具。使用的是什么工具?不明白。
这个就是web.config中的urlrewrite配置节啊。
就是说,在web.config中的urlrewrite配置节中的配置咯。
就是像blog中的那种重写技术。
我用的是ms的urlrewrite组件。