Redirect domain.com to www.domain.com
Hey. I’m trying to implement a permanent redirect from
This is how my
.conf file looks like.
<VirtualHost *:80 *:443> ServerName www.domain.com ServerAdmin email@example.com DocumentRoot /var/www/domain.com/public_html ErrorLog /var/www/domain.com/logs/error.log CustomLog /var/www/domain.com/logs/access.log combined </VirtualHost> <VirtualHost *:80> ServerName domain.com Redirect permanent / http://www.domain.com </VirtualHost> <VirtualHost *:443> ServerName domain.com Redirect permanent / https://www.domain.com </VirtualHost>
This doesn’t work. It works if I want to achieve the opposite (
domain.com) however - obviously after changing a few things.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×