Search

Apache Redirect Non-SSL to SSL Site

  • Share this:
post-title

Open you apache virtualhost conf file like 000-default.conf and update as following example

<VirtualHost *:80>
    ServerName hr.example.com
    ServerAlias hr.example.com
    ServerAdmin admin@example.com
    DocumentRoot /home/hr/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined    
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =hr.example.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>

and finally restart apache
 

Yusuf Khalil

Yusuf Khalil