UrlRewriteFilter equivalent for mod_rewrite

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?


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?

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.

This worked for me

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
            Fitler for checking if file exists.
        <condition type="request-filename" operator="notfile" next="and" />
        <condition type="request-filename" operator="notdir" />
        <to type="redirect" last="true">index.php/$1</to>

Need Your Help

How to expose the internal error message id in play framework 1.2.7 via json?

json playframework-1.x

The play framework 1.2.7 application serves a JavaScript frontend. Almost any messages between the two layers are exchanged as JSON strings. Now I need to change the 500 errors (and possibly others...

How to make C program wait (on Linux)?

c linux wait mpi

How to make C program wait (on Linux)? (I need to use wait with MPI - I need C code please)