Apache: Redirect all requests from one host to another

Updated . Posted . Visible to the public.

In order to redirect all requests from redirecting-host.com to desired-host.com while keeping path and query params unchanged, change your Apache VHost to something like this:

ServerName desired-host.com
ServerAlias redirecting-host.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !^desired-host.com$
RewriteRule ^.*$ http://desired-host.com%{REQUEST_URI} [R=301,L]

Take care to keep all those ^, $ and ! as seen in the example.

Henning Koch
Last edit
Keywords
com, domain, vhost, traffic, config, ssl, https
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2010-12-20 18:30)