how to redirect to an URL using iptables?

If you want the redirected IP/URL to be shown in the browser, you need to send HTTP redirect response to the browser (like 301). Then, the browser will send another request to the new location.

This can not be done using iptables. This needs to be done using any HTTP server/load balancer/proxy.


You can't do this with iptables. You're confusing layers in the networking stack: IP is layer 3 in the OSI model, HTTP is layer 7. See http://en.wikipedia.org/wiki/OSI_model

If you want to redirect URL requests you could use Apache together with mod_proxy.