Mod-rewrite rule for external pages?

You can use the P flag in a mod_rewrite rule to get that substitution URL requested by mod_proxy:

RewriteEngine on
RewriteRule ^myfolder/$ http://other.example.com/anotherfolder/ [P]

Now when a client is requesting /myfolder/ from your server, it will request http://other.example.com/anotherfolder/ and send the response from that server back to the client.


No, tunneling is not possible, you'd have to use a CGI script for this. However, you can redirect:

RewriteRule  ^(.*)  http://new.example.com/$1

with or without the [R] flag, and it will automatically redirect the user to the new domain.

Edit: Apparently it is possible to tunnel requests with mod_proxy and the [P] flag. See Gumbo’s answer.