I've installed ssl on both my pure-domain and www
subdomain. They works as well. I need to redirect all http
protocol requests to https
. Here is the config of the apache:
<VirtualHost *:80>
ServerName lamtakam.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/myweb
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =lamtakam.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:80>
ServerName www.lamtakam.com
DocumentRoot /var/www/html/myweb
RewriteEngine on
RewriteCond %{SERVER_NAME} =lamtakam.com [OR]
RewriteCond %{SERVER_NAME} =www.lamtakam.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<Directory /var/www/html/myweb>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Any idea how can I make that redirection? Currently some cases works as expected and that redirection happens. The only domain that redirection doesn't happen for it is:
Noted that this doesn't work: (however not sure if I place it correctly in the configuration)
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^(www\.)?lamtakam\.com$
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [END,NE,R=permanent]
This used to work but is not recommended as of somewhere in 2010 even. So don't use this:
Those would have been added to
.htaccess
.You should be using this (from the same link):