Make WordPress https Redirect Correctly on Dreamhost

I’ve noticed over multiple installs on my personal account on Dreamhost that getting fully set up can get a bit gnarly. Here’s my sequence:

  1. Get the domain hosted first, and go ahead and tell it to setup a Lets Encrypt cert.
  2. Immediately over on your domain name admin, make the DNS point to Dreamhost.
  3. Cross your fingers.
  4. Install WordPress.
  5. Then be sure to change the default .htaccess to redirect to https via the incantation below.
# Out of the box .htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Change it to:

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

And then pray a little.

Leave a Reply