Mobile app version of vmapp.org
Login or Join
Merenda212

: Switch to https I'm looking to use an .htaccess file to use mod_rewrite to switch the protocol from http:// to https:// when someone hits my website. For instance, once someone goes to: http://www.mywebsite.com/

@Merenda212

Posted in: #Apache #Htaccess #ModRewrite

I'm looking to use an .htaccess file to use mod_rewrite to switch the protocol from to when someone hits my website.

For instance, once someone goes to: www.mywebsite.com/
I'd like the browser to switch to: www.mywebsite.com/
The same goes for the mywebsite.com/ -> mywebsite.com
This is the following code I've been using and I've experienced some odd things so if anyone could provide me with information if this is the right way to do it, or if you have a better way, please provide it. Thanks in advance.

RewriteEngine On
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^(.*)$ www.ebaillv.com/ [R=301,L]

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Merenda212

1 Comments

Sorted by latest first Latest Oldest Best

 

@Nimeshi995

You could try checking for HTTPS instead of whether the port is 443. Also, the rule below matches everything and redirects it to exactly the same as it was but with the https. You could probably throw the [R=301, L] at the end of it if you wanted.

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) %{HTTP_HOST}%{REQUEST_URI}

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme