Wordpress, Raspberry Pi, and Lets Encrypt - 404 on every page except main

Hello,

I’m running my Wordpress site on my Raspberry Pi and have installed Letsencrypt to secure it. Only the main page shows up clean and pretty with https running smoothly. When I navigate to any other page it returns a 404 error, “The requested URL /[url]/ was not found on this server”. The pages still function when using http, but not https.

Let me know what you need to see. I’m very new to this, this being my first self-hosted site. Any assistance is much appreciated!

The 1st thing to check would be that the HTTP and HTTPS VirtualHosts have the same DocumentRoot.

DocumentRoot checks out.

Error log reads that it’s trying to find a page that doesn’t associate with a directory. This seems to be Wordpress specific.

I’m not familiar with WordPress but I’ve seen the same thing happen with Drupal when I forgot to allow the HTTPS virtual host to read .htaccess (AllowOverride all). So maybe it’s something like that?

WordPress stores the URL including http:// in the database. In order to move it to https://, you have to run something to replace the old http url with the new https url. Google “Search Replace DB”. Make sure you back up your database before you do this.

I tried this to no avail.

This is what I have in my .htaccess file.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L]
#  RewriteEngine On
#  RewriteBase /
#  RewriteRule ^index\.php$ - [L]
#  RewriteCond %{REQUEST_FILENAME} !-f
#  RewriteCond %{REQUEST_FILENAME} !-d
#  RewriteRule . /index.php [L]
</IfModule>

## 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

I did comment out quite a bit to try the alternate rules. I can still access the wp-admin panel and I can still see the main page but the other pages are still not viewable.

Well, as I said, I don’t know Wordpress. But this section:

#RewriteRule ^index\.php$ - [L]
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule . /index.php [L]

looks a lot like the part of Drupal’s .htaccess that’s responsible for handling “clean” URLs, and tends to break pages other than the homepage when it’s missing. I’d suggest re-enabling those lines to see what happens.

Failing that, you might get more relevant help on a Wordpress forum.

Thanks for the advice. I’ll see what I can find there.

I finally figured it out. In the default-ssl file I changed the following:

<Directory /var/www/example.com/>    # add FULL directory path                                                            
  Options FollowSymLinks                                                      
  AllowOverride All    # change NONE to ALL                                              
</Directory>

Pretty links work with https now!

I had the same issue, but when I added those settings to my default-ssl.conf file, I broke everything. It stayed broken until I ran a2dissite default-ssl then reenabled it. That managed to give me white screen all around, including the front page.

I set a test page in the root directory that works fine, and ssllabs.con tells me the ssl is good.

Something is giving me white screen, but I can’t figure out what.