Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite problems with php scripts

         

sharkie

5:50 pm on Dec 16, 2004 (gmt 0)

10+ Year Member



Hello,

I am trying to send all traffic for one domain from an apache to another apache server that has a local IP.

I have some trivial rules to do this:

RewriteRule ^/(.*)$ [192.168.2.12:8000...] [P,L]

ProxyPassReverse / [192.168.2.12:8000...]

Both servers are Apache 1.3.x, with php support.
The proxy works fine, except when i access php pages with parameters:

For example :
www.mydomain.com/index.php
works fine, but
www.mydomain.com/index.php?
or
www.mydomain.com/index.php?id=1
returns 404 from the first Apache.

Any other file is correctly handled with or without GET parameters.

PHP works fine on both servers.

I used those rules with an AOLServer instead of the second Apache and TCL instead of PHP, without a problem. I guess the problem can be from my php module on the first apache, messing with mod_rewrite

Please help.

Thanks for reading,
SRK

jdMorgan

7:49 am on Dec 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



sharkie,

Welcome to WebmasterWorld!

> I guess the problem can be from my php module on the first apache, messing with mod_rewrite.

Check your LoadModule order in httpd.conf. If php is loaded *after* mod_rewrite, then it will get control *before* mod_rewrite. The "execute" order is the reverse of the load order on Apache 1.x, and since most people add php at the bottom of the list, this is a frequent problem.

Jim

sharkie

10:16 am on Dec 17, 2004 (gmt 0)

10+ Year Member



Hey,
Thanks for the reply!

I have changed the order of module loading in the first apache config :

Include /etc/apache/mod_php.conf
LoadModule rewrite_module libexec/mod_rewrite.so

AddModule mod_php4.c
AddModule mod_rewrite.c
AddModule mod_access.c

I've also tried to put mod_php4.c below mod_rewrite.c.

However, the problem is still there. php files are returned ok. But php files with parameters are not. I just have to put the '?' at the end of one php file in the URL and i get 404.

I tried to disable php support for the first apache. I checked and php files are returned as text (for the first apache). However, same behaviour, cannot access php files correctly on the second.

Do I need to run mod_rewrite on the second apache,too? It's disabled for the moment.

If you have any idea what can cause this, please post it.

Thanks a lot.

SRK