Forcing HTTPS is removing the trailing slash on domain and causing incorrect URL

Ubuntu 18.04, Apache, php7.2, Wordpress (all plugins deactivated)

Can’t figure this out. Trying to force all to https://www but here is the problem. If I enter the following domain, it loads.

However, if I remove the ‘s’ in the domain

it reverts to this. Notice the trailing slash is gone after the .com, as well as the trailing slash at end of URL.


from the very top of my 000-default.conf

<VirtualHost *:80>
   Redirect permanent /

my htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^44\.66\.7\.278$
RewriteRule ^(.*)$$1 [L,R=301]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Options -Indexes

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.


You should try this :

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} ^$
RewriteRule ^(.*)$1 [QSA,L,R=301]

You must also define in the Wordpress settings your favorite url