i don't want to filter everything by urlrewritefilter,how can i do that

9 views
Skip to first unread message

snail

unread,
Jul 7, 2009, 11:08:43 AM7/7/09
to UrlRewrite
hi,i am a fresh man in urlrewritefilter,can anyone help me to fix my
problem?thx


my web.xml is configured such like

<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/portal/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>


it take effect on all thing that include in portal package,but i
don't want to filter image,css,etc in portal package,how can i do that


thank you very much

best regard!

Ondřej Světlík

unread,
Jul 7, 2009, 4:05:20 PM7/7/09
to urlre...@googlegroups.com
Dne 7.7.2009 17:08, snail napsal(a):
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups "UrlRewrite" group.
> To post to this group, send email to urlre...@googlegroups.com
> To unsubscribe from this group, send email to urlrewrite+...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/urlrewrite?hl=en
> -~----------~----~----~----~------~----~------~--~---

I usually filter such folders but I add a rule just tu pass them
through, something like this:

<rule>
<from>^(/portal/.*)$</from>
<to last="true">$1</to>
</rule>

But I don't filter FORWARDed requests.

But that's only in cases when I don't have my servlet container behind
apache. When I do, I don't pass img/css/other static requests to the
container and serve them with apache.

With regards

Ondrej Svetlik

whostheJBoss

unread,
Jul 7, 2009, 3:46:58 PM7/7/09
to UrlRewrite
You have a couple of options. I usually just use the wildcard and make
a rule such as this:

<rule>
<from>\.(bmp|gif|jpe?g|png|css|js|txt|pdf|doc|xls|xml|htm|html|swf)$</
from>
<to last="true">-</to>
</rule>

This maintains the absolute path for those extensions instead of
rewriting them.

Let me know if you have any other issues.

whostheJBoss

unread,
Jul 7, 2009, 3:42:30 PM7/7/09
to UrlRewrite
I usually use the wildcard in url-pattern and then add a rule like
this:

<rule>
<from>\.(bmp|gif|jpe?g|png|css|js|txt|pdf|doc|xls|xml|htm|html|swf)$</
from>
<to last="true">-</to>
</rule>

This will maintain the absolute file location for those extensions.

On Jul 7, 8:08 am, snail <cool...@gmail.com> wrote:

qizhi chen

unread,
Jul 8, 2009, 3:48:18 AM7/8/09
to urlre...@googlegroups.com

thank you very much,i took your advice,but all images of my website cannot be displayed,why it happen?

i look forward from you
have a nice day!
 
 
2009/7/8 whostheJBoss <dotf...@changethings.org>

qizhi chen

unread,
Jul 8, 2009, 3:40:30 AM7/8/09
to urlre...@googlegroups.com
thank you very much,i filter FORWARDed requests because of integration with struts2,and my rule is like this
<rule>
     <from>^/portal/(\ben/\b|\bzh/\b)*(\bindex\b|\bproduct\b|\breading\b)/*$</from>
     <to type="forward">/portal/$2.action?aa=$2</to>
 </rule>
 
 
2009/7/8 Ondřej Světlík <ond...@svetlik.info>
Dne 7.7.2009 17:08, snail napsal(a):
> hi,i am a fresh man in urlrewritefilter,can anyone help me to fix my
> problem?thx
>
>
> my web.xml is configured such like
>
> <filter-mapping>
>        <filter-name>UrlRewriteFilter</filter-name>
>        <url-pattern>/portal/*</url-pattern>
>        <dispatcher>REQUEST</dispatcher>
>        <dispatcher>FORWARD</dispatcher>
>   </filter-mapping>
>
>
> it take effect on all thing that include in portal package,but  i
> don't want to filter image,css,etc in portal package,how can i do that
>
>
> thank you very much
>
> best regard!
>
Reply all
Reply to author
Forward
0 new messages