apache tutorial - Force HTTPS using virtual host - apache - apache web server - apache server - apache2



Force HTTPS using virtual host in apache

Use Redirect to force users to connect to the secureURL.

<VirtualHost *:80>
    ServerName example.com
    SSLProxyEngine on
    Redirect permanent / https://secure_example.com/
</VirtualHost>
click below button to copy the code. By Apache tutorial team

The rest of the configuration can be put in the ssl virtual host (port 443) since everything is redirected.

<VirtualHost _default_:443>
    ServerName secure_example.com
    ServerAdmin [email protected] 
    DocumentRoot /var/www/domains/secure_example.com/html
    ErrorLog /var/log/secure_example.com/error.log
    CustomLog /var/log/secure_example.com/access.log common
    SSLEngine On
    ...
</VirtualHost>
click below button to copy the code. By Apache tutorial team

Related Searches to Force HTTPS using virtual host in Apache