I have an old application with URLs of the form...
http://apps.myserver.com/appname/viewItem.akt?p=123
I am replacing this old app with one that has URLs like...
http://appname.myserver.com/item/123
I've tried adding several different rewrite rules to httpd/httpd.conf
and restarting the server, but I keep getting 404 errors.
A couple things I've tried...
RewriteEngine on
RewriteRule ^.*viewItem.akt\?p=([0-9]*)$ http://appname.myserver.com/item/$1 [R]
Or...
RewriteRule ^/appname/viewItem.akt\?p=([0-9]*)$ http://appname.myserver.com/item/$1 [R]
The result is always "The requested URL /appname/viewItem.akt was not found on this server", as if the rewrite rule weren't even there.
What I'm getting in the access log is...
[IP address] - - [09/Sep/2011:21:27:37 -0700] "GET /appname/viewItem.akt?p=1018 HTTP/1.0" 404 248
I tested all my regexes in Rubular to make sure they match the incoming request.
What am I missing?
In case it's relevant, the old application was a Java app running under Tomcat, and I had a ProxyPass set up like this...
(I'm showing these lines commented out, as they are when I'm trying to get the rewrite rule to work.)
# ProxyPass /appname http://apps.myserver.com:8080/appname
# ProxyPassReverse /appname http://apps.myserver.com:8080/appname
But that shouldn't matter right? As long as my rewrite rule matches the request it should send it along properly, shouldn't it?
Try this:
%1
to back reference to Rewrite Condition?
at the end of substitution to remove the rest of query stringBut it seems you are mixing up
mod_rewrite
withmod_proxy
. Which Apache version are you running?Are you sure that
mod_rewrite
is correctly loaded?Otherwise, using the directive RewriteLog with an according RewriteLogLevel should help you figuring out if your RewriteRule is taken into account while requesting your page, and if the regular expression matches or not.
I don't know if this suits your need, but these things drive me crazy too. I always try to simplify as much as I can.
This appears to work in my tests:
RewriteRule p=([0-9]*)$ http://appname.myserver.com/item/$1