Reputation: 1
Both HTTP and HTTPS working depends on what user types in browser. Example I have a website named http :// example . com and it is working and live, then i want to make it work for something like https: // example . com.
if the user typed
http: //example .c om
it will work, likewise
https: //example .c om
I have htaccess file like this
Options FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.html
I have tried using this
RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$
RewriteRule ^(.*)$ - [env=askapache:%2]
this
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(.*)$ https: // example. com/$1 [P,L]
RewriteRule ^(.*)$ http:// example . com/$1 [P,L]
and this
RewriteCond %{HTTPS} =on
RewriteRule ^(.*)$ - [env=ps:https]
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ - [env=ps:http]
still not working. I can only access http but https I can't. that example.c o m is only a simple web page and does not include any security risks. there are whitespaces on my link because I can't post more than 1 link
Upvotes: 0
Views: 82
Reputation: 87
HTTPS is not something simply enabled via htaccess, it needs to be enabled and configured on your webserver using a signed SSL certificate. If you are using a hosting provider such as bluehost or hostgator, you will need to contact their support team to get HTTPS set up on your site. Otherwise:
Upvotes: 0
Reputation: 41249
To redirect from http to https, you can use the following Rule :
RewriteEngine on
#Check if we are already not on https
RewriteCond %{HTTPS} !on
#Then, redirect http to https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NC,L,R]
Upvotes: 0