URL Redirect via Apache VirtualHost

Warning message

Warning: This post is slightly older.

It may be that the content is out of date, links are outdated or that no one responds to new comments.

With the following configuration for Apache, you can simply redirect to another domain.

<VirtualHost *:80>
  ServerName www.foo.com
  Redirect 301 / http://www.bar.com/

Now, all requests to www.foo.com redirect via 301 HTTP status code (Moved Permanently) to www.bar.com. As Goodie: Even all paths redirects to the other domain (e.g. http://www.foo.com/foo redirects to http://www.bar.com/foo).

If you set the directive ServerAlias to subdomains or *.domain.com*, you can redirect these or all subdomain in one step to the appropriate domain.

English | 19. February 2013
Stored in
Filled under

Add new comment