Hi, I have two domains, domain.web and domain.info, y need redirect to:
https://www.domain.web

http://domain.web          ---> https://www.domain.web
http://www.domain.web   ---> https://www.domain.web
https://domain.web        ----> https://www.domain.web <https://www.domain>
http://domain.info           ---> https://www.domain.web
http://www.domain.info   ---> https://www.domain.web
https://domain.info         ---> https://www.domain.web
https://www.domain.info  ---> https://www.domain.web

Before asking I read many posts in stackoverflow, serverfault, and I have
managed to build this configuration that works for me correctly, I would
like to know if this is the best way to do it.

<VirtualHost *:80>
    ServerName domain.web
    ServerAlias www.domain.web www.domain.info domain.info

    DocumentRoot /home/domain/public_html

    RewriteEngine On

    RewriteCond %{SERVER_PORT} 80
    RewriteCond %{HTTP_HOST} ^domain\.(info|web) [NC,OR]
    RewriteCond %{HTTP_HOST} ^www.domain\.(info|web) [NC]
    RewriteRule (.*) https://www.domain.web$1 [R=301,L]
</VirtualHost>

<VirtualHost *:443>
    ServerName domain.web
    ServerAlias www.domain.web www.domain.info domain.info

    DocumentRoot /home/domain/public_html

    RewriteEngine On

    RewriteCond %{SERVER_PORT} 443
    RewriteCond %{HTTP_HOST} ^domain\.(info|web) [NC,OR]
    RewriteCond %{HTTP_HOST} ^www.domain\.(info) [NC]
    RewriteRule (.*) https://www.domain.web$1 [R=301,L]
</VirtualHost>

Regards,

-- 


*Wilmer Arambula. *

Reply via email to