Forum Moderators: phranque
I am trying to make my RewriteRule work preserving the hostname of the Apache server. In my RewriteRule I want to get the request redirected to the external Web server while preserving the hostname of the Apache server in the URL. Here is the issue:
If I have [P] defined in the RewriteRule :
RewriteRule ^test(.*)$ [target.example.com:80...] [P,L]
I am getting the Apache hostname preserved in the URL , but the "test" string is not removed from the target URI. So my URL (after RewriteRule) looks like : [apacheserver.example.com...] defined in the $1>.... . Basically the whole URI is getting redirected to the target server (w/o expected removal of "test")
If I remove [P] flag from the RewriteRule, the rule works fine although I am not getting the Apache host name preserved in the URL.
Any help or pointers are highly appreciated,
Thanks and regards,
Mike
What happens if you do this?
RewriteRule ^test(.*)$ $1 [C]
RewriteRule (.*) http://target.example.com:80/$1 [P]
Jim
Jim
[edited by: jdMorgan at 2:42 am (utc) on Dec. 9, 2008]
I thought that there could went sthg. wrong while the proxy-handler canonicalises the URL using r->uri somewhere (which should still contain the initial value of that request_rec), but that's not the case.
Switching
LogLevel do debug might be a good idea as well since mod_proxy et al. will log a lot in that case. A RewriteLog should show you the processing of the part done by mod_rewrite. By default, until apache 2.3, apache 2.x should compile with and statically link against a shipped copy of the PCRE library (scrlib folder) unless configured with
--with-pcre=... while compiling not to do so.