Aug 13, 2011

Apache server rewrite rules: how to avoid “implicitly forcing redirect (rc=302)”?


I’ve got a very annoying problem:

our webserver handles 2 (more actually but let’s say 2 for a simpler example):


Here’s what I want to do:




So here’s my rewriterule:

RewriteCond %{SERVER_NAME} (([a-z]+.)*)pretassuragentimmobilier.(fr|com)
RewriteRule   ^(.+)$1 [E=THEME:pretassur_agent,QSA]
# if THEME not empty, set it :
RewriteCond   %{ENV:THEME} ^(.+)$
RewriteRule (.*) $1?IDP=%{ENV:THEME} [QSA]

The big (huge) problem is: let’s have a look at the rewrite logs:

[] (5)
=> setting env variable 'THEME' to 'pretassur_mandataire'
=> (2) implicitly forcing redirect (rc=302) with

Aaaaaaaaarg! “implicitly forcing redirect” => I don’t want that ! I want to internally redirect to, not to make a real redirect!

Now if you type: it is redirected to (try it) I don’t want that! I want to display this page but without touching the original host!

Any idea?

Thanks a lot!


Even if they are on the same server you cannot do internal redirects between two different vhosts. Hence the external (302) redirect.

To accomplish what you want you could use the “‘proxy|P’ (force proxy)” option.

Related posts:

  1. Apache .htaccess 301 permanent redirect
  2. Apache rewrite rules behind a nginx proxy
  3. .htaccess modify rules and redirect if there’s .php in the url
  4. Why do some rewrite rules fail while AJP is serving all of my requests to Tomcat?
  5. Rewrite Conditions Backreferences passed to all rules?

Leave a comment