Redirect HTTP to HTTPS at PCextreme

Gewijzigd op Ma, 24 Jun om 12:04 PM

When you use SSL for your website at PCX it might be necessary to force visitors to a https connection. This guide shows you how to do this. You will need a free SSL certificate, which is included whenever you have a domainname and webhosting from us.


Table of contents


Introduction 

If you’re using a WordPress we recommend Really Simple SSL. This plugin does all of the redirecting for you. Otherwise a couple of lines of code can fix the problem. These lines can be added to your website’s .htaccess file. It will direct visitors from HTTP to HTTPS. 


Code

Redirect HTTP to HTTPS with or without www prefix

RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Redirect HTTP to HTTPS always using www prefix 

RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Redirect HTTP to HTTPS never using www prefix 

RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC] RewriteRule (.*) https://%1%{REQUEST_URI} [L,R=301]

Redirect HTTPS (with www prefix) to HTTPS (without www prefix) 

RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Was dit artikel nuttig?

Dat is fantastisch!

Hartelijk dank voor uw beoordeling

Sorry dat we u niet konden helpen

Hartelijk dank voor uw beoordeling

Laat ons weten hoe we dit artikel kunnen verbeteren!

Selecteer tenminste een van de redenen
CAPTCHA-verificatie is vereist.

Feedback verzonden

We stellen uw moeite op prijs en zullen proberen het artikel te verbeteren