I’ve set up a droplet for a WordPress site using the provided 1-Click installer. This installs the latest LAMP stack along with Wordpress. I also created a SSL certificate for my site using
certbot. I’ve modified my HTTP virtual host file to always perform a redirect to HTTPS.
Everything works as expected except for this one strange behavior. If the trailing slash on the requested URL is not provided by the user, the server performs a 301 redirect to a URL which replaces my domain with the server’s IP address. For example, requesting https://subdomain.domain.com/forum forces a redirect to https://188.8.131.52/forum/. Since my SSL certificate is tied to my domain, it causes a big warning to appear in the browser. I’ve noticed this behavior will always happen regardless of the sub-directory (i.e. will also happen if trying to access http://subdomain.domain.com/wp-includes).
The ONLY exception I’ve noticed with this is when I created a
/test directory in the root and created a simple
index.html file to display “Hello World”. Trying to access https://subdomain.domain.com/test worked as expected and added the trailing slash without a redirect.
I’ve tried countless things in the
.htaccess files without luck. I’m not even confident these files will help. I’ve purposely put a line of garbage in them to see if they’re even active during this redirect and they’re not. The server won’t trigger an error unless I use a URL with a trailing slash. I’ve tried this experiment with the root
.htaccess file as well as the one in my
/forum directory. However, seeing as how my Hello World experiment was successful (without any
.htaccess file), I’m really stumped!
Just for the full background, I already have a fully function site at “domain.com” with a shared hosting provider. I’m experimenting with a migration to DO using this droplet. I’m fiddling around with both sites in my browser, so I’m hoping this isn’t an issue with cookies.
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.
Click below to sign up and get $100 of credit to try our products over 60 days!