Mod_rewrite not adding REDIRECT_URL environment variable

apache-2.2mod-proxymod-rewritevirtualhost

We run a site based on Zend Framework using apache httpd (2.2) with mod_rewrite for SEO and usability friendly URL:s. Recently we added mod_proxy (and mod_proxy_balancer, mod_proxy_http, mod_rpaf) for setting up a loadbalancer virtual-host.

Our setup now looks like:

external.site.com (vhost on server1.site.com with reverse proxy)
|-internal1.site.com (vhost on server1.site.com) 
|-internal2.site.com (vhost on server2.site.com)

Where internal1 & internal2 serves most of the dynamic content and external serves static content plus some admin type pages. All the vhosts have got the same code and .htaccess setup.

The problem is that on external.site.com the RewriteRule doesn't add the correct headers to the request environment, specifically REDIRECT_URL which we and ZendFramework depend upon. Everything works fine for the requests that are forwarded to the internal vhosts.

The relevant parts of the httpd.conf:

<VirtualHost *:80>
  ServerName external.site.com
  DocumentRoot /opt/www/htdocs/
  CustomLog "/var/log/httpd-proxy-access.log" combined

  <Proxy balancer://backend/>
    Balancermember http://internal1.site.com
    Balancermember http://internal2.site.com
    ProxySet lbmethod=byrequests
  </Proxy>
  ProxyRequests Off
  <Proxy *>
    Order deny,allow
    Allow from all
  </Proxy>
  ProxyPass /static/ !
  ProxyPass /config/ !
  ProxyPass / balancer://backend/
  ProxyPassReverse / balancer://backend/
</VirtualHost>
<VirtualHost *:80>
  ServerName internal1.site.com

  RPAFenable On
  RPAFproxy_ips 127.0.0.1
</VirtualHost>

From the .htaccess file:

RewriteEngine on 
RewriteCond %{REQUEST_URI} !^.*robots.txt
RewriteCond %{REQUEST_URI} !^.*/static/.*
  RewriteRule .* index.php [L]

php_flag magic_quotes_gpc off 
php_flag register_globals off

Because there only is a problem on the external vhost we assume it is a problem with the mod_proxy and mod_rewrite combination. Any ideas?

Regards

Best Answer

I am by no means an expert, but I had to put [OR] to my file. As stated here

RewriteEngine on 
RewriteCond %{REQUEST_URI} !^.*robots.txt [OR]
RewriteCond %{REQUEST_URI} !^.*/static/.*
RewriteRule .* index.php [L]