This question already has an answer here:
- http to https through .htaccess 14 answers
How to tell if http://ttt.com or http://www.ttt.com is used by the user, redirect it to https://www.ttt.com ?
httpd.conf:
<VirtualHost *:80>
ServerName www.ttt.com
ServerAlias ttt.com
DocumentRoot /home/www/html/ttt/public
<Directory /home/www/html/ttt/public>
#Options ExecCGI
#AddDefaultCharset utf-8
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
.htaccess :
RewriteEngine On
############################################
## always send 404 on missing files in these folders
#RewriteCond %{REQUEST_URI} !^/(files)/
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Here you go: https://wiki.apache.org/httpd/RedirectSSL
From https://httpd.apache.org/docs/trunk/mod/mod_alias.html#redirect:
If you want both the
www.example.com/*
and theexample.com/*
to be redirected you could make two VirtualHost with different ServerName or you can use the Rewrite plugin.Try the following Code at the main directory .htaccess file :
You can do it from the httpd.conf with the following:
Or from the .htaccess file: