Enabling SSL on wordpress results in 404

I had exactly the same problem and the solution for me was to add these lines to /etc/apache2/sites-enabled/default-ssl.conf, which is my SSL-enabled website’s configuration file:

        <Directory /var/www/html/>
                AllowOverride All
        </Directory>

Of course, this assumes DocumentRoot /var/www/html. Change accordingly if is this is different in your setup.

The thing is that WordPress uses .htaccess rules to process the URLs and for them to work, AllowOverride All needs to be in the server’s configuration file.

In my situation, the configuration for the non-SSL and SSL-enabled variants were in a separate files. The non-SSL configuration had AllowOverride All all along, and so everything was working fine. Once I had enabled the SSL, the other configuration file came into play and didn’t have the required AllowOverride All setting.