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>
   ServerName example.com
   Redirect permanent / https://www.example.com/

my htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^44\.66\.7\.278$
RewriteRule ^(.*)$ https://www.example.com/$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

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.

1 answer


You should try this :

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

RewriteCond %{HTTP_HOST} ^yourwebsite.com$
RewriteRule ^(.*) https://www.yourwebsite.com/$1 [QSA,L,R=301]

You must also define in the Wordpress settings your favorite url

Submit an Answer