Jun 26, 2015

How to make WordPress custom permalinks work with SSL on Ubuntu 14.04

English: The logo of the blogging software Wor...
English: The logo of the blogging software WordPress. Deutsch: WordPress Logo 中文: WordPress Logo (Photo credit: Wikipedia)
I manage a WordPress server, and the way this particular server works is weird. We have the domain name currently pointing at a Windows IIS site that uses rewrite rules to proxy everything over to Wordpress running on an Ubuntu Apache server. Right now the IIS server handles SSL, so there aren't any weird issues.

Well pretty soon we are going to remove the Windows IIS server from the equation, and we're going to point DNS directly to the WordPress server. The problem is that we still want SSL, and we currently use custom permalinks. The permalinks we use are /%category%/%postname%/.

Ok, well the problem comes down to how WordPress handles SSL, and apparently if you don't use permalinks it works fine with SSL, but if you have permalinks enabled with SSL, then your pages will come up with page not found errors.

To fix this, on Ubuntu 14.04 anyway, you need to edit your SSL Apache config file, and under the line that says:
DocumentRoot /var/www/yoursitedirectory
You need to paste the following:
<Directory /var/www/yoursitedirectory/>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
After you add that and save your config file, you need to restart Apache to see the changes take effect:
service apache2 restart
You may need to enable the Apache rewrite module for this to take effect, but it should generally be enabled anyway for WordPress. If it's you you can enable it by running:
a2enmod rewrite
Boom! Now SSL will work on your WordPress server without any weird page not found errors!

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | stopping spam