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

Posted by Olivier Pons on Server Fault See other posts from Server Fault or by Olivier Pons
Published on 2010-12-21T09:11:18Z Indexed on 2010/12/21 9:55 UTC
Read the original article Hit count: 275

Hi!

I've got a very annoying problem:

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

  • pretassur.fr
  • pretassuragentimmobilier.fr

Here's what I want to do: change

(whatever1).pretassuragentimmobilier.fr(/whatever2)

to

(whatever1).pretassur.fr(/whatever2)?theme=agentimmobilier

So here's my rewriterule:

RewriteCond %{SERVER_NAME} (([a-z]+\.)*)pretassuragentimmobilier.(fr|com)
RewriteRule   ^(.+)        http://%1pretassur.fr$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:

[pretassurmandataireimmo.com] (5)
=> setting env variable 'THEME' to 'pretassur_mandataire'
[pretassurmandataireimmo.com]
=> (2) implicitly forcing redirect (rc=302) with http://pretassur.fr/

Aaaaaaaaarg! "implicitly forcing redirect" => I don't want that ! I want to internally redirect to pretassur.fr, not to make a real redirect!

Now if you type: http://pretassurmandataireimmo.com it is redirected to http://pretassur.fr/?IDP=pretassur_mandataire (try it) I don't want that! I want to display this page http://pretassur.fr/?IDP=pretassur_mandataire but without touching the original host!

Any idea?

Thanks a lot!

© Server Fault or respective owner

Related posts about apache

Related posts about mod-rewrite