Forum Moderators: phranque

Message Too Old, No Replies

rewrite rule not working in Apache2.0

rewrite rule not working in Apache2.0

         

sjwood0

11:29 am on Feb 28, 2007 (gmt 0)

10+ Year Member



Hello All

I'd be very grateful of some Apache Gurus help with this. I have a rewrite rule that was previously working fine on an Apache1.3 but doesn't work on Apache2.0. Looking at the rewrite log the rewrite bit works OK and it's down to what apache does when a path you type in isn't there(because in this case it's a parameter I'm passing to something else). How to I change my setup so Apache doesn't see this as a forbidden request?

Here's the address I type in... [some-server.com...]
In Apache1.3 this gets a "400 Bad Request" error but the proxy/rewrite bit works
In Apache2.0 this gets a "403 Forbidden" error and doesn't

And the httpd.conf entry (same in both servers)....
<VirtualHost _default_:80>
ServerName some-server.com
DocumentRoot "/opt/apache2/htdocs"
RewriteEngine On
RewriteLog "/opt/apache2/logs/rewrite1.log"
RewriteLogLevel 9
RewriteCond %{REQUEST_URI} ^/parameter/([a-zA-Z0-9_]+)$ [NC]
RewriteRule ^/parameter/([a-zA-Z0-9_]+)$ [sometomcatserver.com?urlsuffix=$1&ipaddress=%{REMOTE_ADDR}...] [P]
</VirtualHost>

Heres a snip of the 1.3 rewrite log showing it working.....

192.168.219.192 - - [28/Feb/2007:10:54:07 +0000] [some-server.com/sid#ad70
8][rid#c7d70/initial] (3) split uri=http://sometomcatserver.com?urlsuffix=sss&ipaddress=192.168.219.192 -> uri=http://sometomcatserver.com, args=urlsuffix=sss&ipaddress=192.168.219.192
192.168.219.192 - - [28/Feb/2007:10:54:07 +0000] [some-server.com/sid#ad70
8][rid#c7d70/initial] (2) forcing proxy-throughput with [sometomcatserver.com...]
192.168.219.192 - - [28/Feb/2007:10:54:07 +0000] [some-server.com/sid#ad70
8][rid#c7d70/initial] (1) go-ahead with proxy request proxy:http://sometomcatserver.com [OK]

And a snip of the 2.0 rewrite log showing it NOT working.....

6cc10/initial] (3) applying pattern '^/parameter/([a-zA-Z0-9_]+)$' to uri '/parameter/sss'
64.35.70.108 - - [28/Feb/2007:10:17:42 +0000] [sometomcatserver.com/sid#81259b0][rid#816cc10/initial] (4) RewriteCond: input='/parameter/sss' pattern='^/parameter/([a-zA-Z0-9_]+)$' => matched
64.35.70.108 - - [28/Feb/2007:10:17:42 +0000] [sometomcatserver.com/sid#81259b0][rid#816cc10/initial] (2) rewrite /parameter/sss -> [sometomcatserver.com?urlsuffix=sss&ipaddress=64.35.70.108...]
64.35.70.108 - - [28/Feb/2007:10:17:42 +0000] [sometomcatserver.com/sid#81259b0][rid#816cc10/initial] (3) split uri=http://sometomcatserver.com?urlsuffix=sss&ipaddress=64.35.70.108 -> uri=http://sometomcatserver.com, args=urlsuffix=sss&ipaddress=64.35.70.108
64.35.70.108 - - [28/Feb/2007:10:17:42 +0000] [sometomcatserver.com/sid#81259b0][rid#816cc10/initial] (2) forcing proxy-throughput with [sometomcatserver.com...]

jdMorgan

4:02 pm on Mar 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't see anything major that is wrong. However, it may be that Apache 1.3 is more forgiving of the URL-syntax error in the substitution URL than Apache 2.x. I would guess that it might have to do with the execution order of mod_dir and mod_rewrite, and possibly some other modules you're using. Specifically this:

RewriteRule ^/parameter/([a-zA-Z0-9_]+)$ http://sometomcatserver.com?urlsuffix=$1&ipaddress=%{REMOTE_ADDR} [P]
should be:
 RewriteRule ^/parameter/([a-zA-Z0-9_]+)$ http://sometomcatserver.co[b]m/?u[/b]rlsuffix=$1&ipaddress=%{REMOTE_ADDR} [P]

as a slash should always follow the domain part of the URL.

I hope that helps, since it's the only thing I could spot.

Jim

sjwood0

11:26 am on Mar 9, 2007 (gmt 0)

10+ Year Member



Thanks Jim

I'll try this and let you know if I have any success, it's a really random problem....typical!

Steve