How to Redirect a URL in a Virtual Host

By | 2013/01/18

Redirecting a URL in a virtual host is a snap! I’ll show you how.

Scenario: you have a server that receives but you want that to redirect to

First you will want to add this to your /etc/apache2/ports.conf (Debian or Ubuntu) or /etc/httpd/conf/httpd.conf (Red Hat or CentOS) if you have not already:

NameVirtualHost *:80

Next, setup a virtual host with the following to have it redirect to an alternate URL:

<VirtualHost *:80>
      Redirect 301 /

Done! When a user visits they will be redirected to