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

February 6, 2019 962 views
Ubuntu 18.04 Configuration Management PHP Apache WordPress

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
1 Answer


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

Have another answer? Share your knowledge.