I’ve just started to set up SSL with lets encrpyt on several of my sites and have noticed that after adding the redirect script to force https and extra / is being added to the url resulting in page loading errors.
|OS|CentOS Linux 7.2.1511 (Core)|
|Plesk version|12.5.30 Update #76, last updated at May 8, 2018 02:21 AM|
The script I’m adding comes from Plesks own KB
The script is
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,QSA]
I’ve added it to the Apache & nginx Settings > Additional directives for HTTP field as per Plesk instructions
I dont seem to see a patter.
This site looks fine no-limit.org.uk
This one doesn’t, it has the extra / at the end of the url.
Can anyone tell me where that extra / at the end if the URL comes from, I feel if I can get rid of that the problem will be solved. Maybe I’m making a newbie error!
I think you might be able to change it to https://%{HTTP_HOST}$1 and get rid of the slash, since the slash is probably already included in the string matched by the (.*) in the match pattern.
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
… where example.com is replaced with your actual domain name. I believe if there are multiple ServerAlias names, then each one will get its own RewriteCond line (e.g. RewriteCond %{SERVER_NAME} =www.example.com if you have a www.example.com alias).
Certbot places that only in the HTTP virtual host, not in the HTTPS virtual host (to avoid a redirection loop).
But I think the version that Plesk gave you should be fine too, once you get rid of the extra slash. The mod_rewrite syntax is very broad and flexible and so there are a lot of different ways to write this kind of rewrite rule.