Forum Moderators: phranque

Message Too Old, No Replies

rewrite problem with backend server

         

phranque

11:20 pm on Mar 27, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



i am having a strange problem with a mod rewrite and i think it has something to do with using the ProxyPass directive.

here are the relevant parts of the virtual host section of the config file:

<VirtualHost w.x.y.z:80>
UseCanonicalName On
DocumentRoot /www/example
ServerName www.example.org

RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\.example\.org
RewriteRule ^/(.*) http://www.example.org/$1 [R=301,L]

ProxyPass /index.cgi http://www.example.org:85/index.cgi
ProxyPassReverse /index.cgi http://www.example.org:85/index.cgi
</VirtualHost>

the purpose is to canonicalize the host name.

if i try any of the following i get the expected 301 redirect:
http://example.org/ redirects to http://www.example.org/
[x.example.org...] redirects to http://www.example.org/
[x.example.org...] redirects to http://www.example.org/test.cgi
[x.example.org...] redirects to http://www.example.org/test.cgi?some_good_param_string

all good so far.
however - if i use index.cgi in the request string it fails to canonicalize, such as:
http://example.org/index.cgi
[x.example.org...]
[x.example.org...]

the content served for these urls is as expected - it just doesn't do the expected 301.

any help or suggestions appreciated...

jdMorgan

3:53 am on Mar 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Two points:

If you're sending requests to a back-end server, you probably only need a reverse proxy, so be sure that the ProxyPass is really required.

Also, cgi-bins are often "Aliased" at the top, and this can have the effect of by-passing mod_rewrite. In that case, a copy of the canonicalization rules in .htaccess in the cgi-bin directory itself may help.

Jim