lighty's life

lighty developer blog

X-Sendfile's New Friend: X-Rewrite-*

Today on IRC I got a question on:
Fobax can you x-send-file from fast-cgi to a proxy request?
Or asked in another way ?
Can you use a mod_proxy_core backend to rewrite a URL or a Host header ?
After 30 minutes of coding ... Yes, you can ... Some tweaking and here and there and we had:
proxy-core.allow-x-rewrite = "enable"
which allows you to send:
HTTP/1.0 200 OK
X-Rewrite-URI: /pi.php
X-Rewrite-Host: www.foobar.com
as response and lighty will replace both values and the original request and start the whole request from scratch. Here I rewrite the incoming request to use another internal Host and a new URI.

What is this good for ?

* rewriting http://user.example.org/ to http://xample.org/~user/ * denying access to host with unwanted content based on the Hostname * filtering in general Do you have other examples ?