日期:2014-05-20  浏览次数:21043 次

再发一贴,如何使用正则表达式,对url进行重写(urlRewrite)?
再发一贴,如何使用正则表达式,对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>


------解决方案--------------------
......没明白你使用的是什么工具。
------解决方案--------------------
大病中...非常难受外加看不懂你说什么...不好意思
------解决方案--------------------
兄弟我也在郁闷中啊