views:

387

answers:

2

Hi gentlemen

I want to do Url rewrite in Tomcat using UrlRewriteFilter This is the rule would like in mod_rewrite apache

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*) index.php/$1 [L]

I'm confused in how to check the request filename if it's not a file or not a folder in UrlRewriteFilter

Can anybody help me?

A: 

Hi,

Actually, you don't have to worry about that. Apache's mod_rerwite module take care of that for you. Try it .. If you try to access a folder or a file within the server, it will open it, othewhise it will apply the RewriteRule you have in there.

yoda
Yes it worked on Apache but currently I'm trying to make it work on Tomcat. So it will need to be converted to UrlRewriteFilter condition.Thank you for answering
Erwin
A: 

You can't. Well, you can if you're using version UrlRewriteFilter 3.2 and you will write your own custom class-rule to check for it; but that's not really what UrlRewriteFilter was designed for.

This definitely belongs in Apache's mod_rewrite, especially considering that you have index.php in your example. Why would that request even be forwarded to / served by Tomcat?

ChssPly76
Hello,Yes by looking at the rule index.php, that may seem strange to be served by Tomcat.Well actually my program is written on php. And I'm using PHP Java Bridge to run it on Tomcat.And yes it run pretty well, except when I need Url RewriteIn Apache, the rule is easy to write. Well because by what you said I can if I write my own custom class, I will try to research this topicPS : I run php on Tomcat because I wanted to use Jasper Reports for my php applicationIf you know how to integrate Jasper Reports the other way, Please be kind to let me know
Erwin
Erwin, I would suggest that you look into running Apache in front of Tomcat. Have your PHP application run in Apache and use regular mod_rewrite (much easier and most likely faster then doing either in Tomcat) and run Jasper in Tomcat. You can then invoke Jasper reports via local URI with necessary parameters. Take a look at http://tomcat.apache.org/connectors-doc/webserver_howto/apache.html on how to run Apache with Tomcat; you can also do that via mod_proxy. Google (http://www.google.com/search?q=run+apache+with+tomcat) has quite a few results as well
ChssPly76