Mobile app version of vmapp.org
Login or Join
Gonzalez347

: Duplicated webpage (HTTP & HTTPS) my webpage is duplicated because of the SSL certificate (http:// example.com and https:// example.com). I want to redirect from http to https. But I have two

@Gonzalez347

Posted in: #DuplicateContent #Https #SecurityCertificate

my webpage is duplicated because of the SSL certificate (http:// example.com and example.com). I want to redirect from http to https. But I have two questions:

If my webpage has several pages (Home, About, Contact...), should I make a redirect for each page? Or just with the example.com and then the rest of its pages will redirect correctly?

I consulted in several websites and forums and I get two different codes from them for the .htaccess file:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) example.com%{REQUEST_URI} [L,R=301]


And there is the other one:

<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} off
RewriteRule (.*) www.example.com/ [R=301,L,QSA]
</IfModule>


Which one is the correct one or the best one for redirecting from HTTP to HTTPS?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Gonzalez347

1 Comments

Sorted by latest first Latest Oldest Best

 

@Barnes591

If my webpage has several pages (Home, About, Contact...), should I make a redirect for each page? Or just with the example.com and then the rest of its pages will redirect correctly?


Neither. What you want to do is redirect any http request to https for any URL. Both of the .htaccess directives you posted above will do that.


Which one is the correct one or the best one for redirecting from HTTP to HTTPS?


They are both correct, up to a point. Both snippets assume Apache is the web server. The first snippet assumes mod_rewrite is present, the second checks it first but either one should work. The only other significant difference is that the second one calls the QSA flag which preserves any query strings on the rewrite. You may or may not need that.

Also, both snippets call the L (Last) flag which indicates this is the last rewrite. If you are performing additional rewrites after this one, remove the L flag.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme