Wordpress Permalinks 404 under SSL

December 28, 2015 5.6k views
WordPress Apache Ubuntu

I started a Ubuntu 14.04 droplet with the 1-click preconfigured Wordpress stack. I then set up my SSL certificate following this guide: https://www.digitalocean.com/community/tutorials/how-to-create-a-ssl-certificate-on-apache-for-ubuntu-14-04 except I scp'ed my real cert in instead of creating a self-signed. I enabled the default-ssl site and then restarted the service. The homepage at https://blog.mysite.com works great. However when you click a link to a permalink, it 404s. However, going to the same link without ssl, at http://blog.mysite.com/2015/post-title works fine. Mod_rewrite seems to be enabled and working fine as long as it's not secure. Here are the relevant configs:


<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        <Directory /var/www/html/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


<IfModule mod_ssl.c>
    <VirtualHost _default_:443>
        ServerAdmin tech@mysite.com
        ServerName blog.mysite.com
        DocumentRoot /var/www/html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        #   SSL Engine Switch:
        #   Enable/Disable SSL for this virtual host.
        SSLEngine on

        #   A self-signed (snakeoil) certificate can be created by installing
        #   the ssl-cert package. See
        #   /usr/share/doc/apache2/README.Debian.gz for more info.
        #   If both key and certificate are stored in the same file, only the
        #   SSLCertificateFile directive is needed.
        SSLCertificateFile  /etc/apache2/ssl/*.mysite.com.chained.crt
        SSLCertificateKeyFile /etc/apache2/ssl/*.mysite.com.key

        <FilesMatch "\.(cgi|shtml|phtml|php)$">
                SSLOptions +StdEnvVars
        <Directory /usr/lib/cgi-bin>
                SSLOptions +StdEnvVars

        BrowserMatch "MSIE [2-6]" \
                nokeepalive ssl-unclean-shutdown \
                downgrade-1.0 force-response-1.0
        # MSIE 7 and newer should be able to use keepalive
        BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown



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

# END WordPress

Everything looks pretty good. My only guess is maybe changing <FilesMatch> in default-ssl.conf?

1 Answer

I found the answer here: http://stackoverflow.com/questions/11253185/404-error-with-wordpress-ssl?rq=1

Duplicating the Directory tag from my default config to my ssl config and restarting fixed the problem.

Have another answer? Share your knowledge.