Catch all virtualhost with 301 redirect in apache

I you want to make sure all traffic only uses your preferred domain namn you can create a catch all virtual host in apache and redirect to the virtual host with the preferred domain name.

On your apache node select config and edit the httpd.conf file. Replace the current <VirtualHost ... section with the following and replace with your domain name.

<VirtualHost *:80>
 DocumentRoot /var/www/webroot/ROOT
 ErrorLog logs/mydomain-error_log
 CustomLog logs/mydomain-access_log common

<VirtualHost *:80>
 ServerAlias *
 Redirect 301 /
 ErrorLog logs/redirect-error_log
 CustomLog logs/redirect-access_log common

 In this example all traffic that is not will be redirected to that domain.


Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request



Please sign in to leave a comment.