Pages

Thursday, September 3, 2015

Wordpress Permalinks not working?

When creating a local website on your own webserver running Apache2 and using Wordpress, you will see that the URL is created by referring to different kind of ID's. This could be Post ID's, Category ID's, Page ID's and so on. So I went into the Wordpress Administration Panel and told it to use permalinks instead. Hoping this would make the URL's a little prettier...

And sure enough; It did.
The only problem was that my stupid server couldn't find this permalink.

After a little searching I figured that my server/website needed 3 requirements to be met for this to work as expected. These three requirements are easy to fix on your own server by making the correct editing in the following parts:


1)   Apache2

There are actually 2 requirements  for the Apache2 setup.


Requirement 1)
The Apache module mod_rewrite MUST be installed and enabled. This can be accomplished by running:

sudo a2enmod rewrite && sudo service apache2 restart


Requirement 2)
The host directory configured in Apache2 must allow overriding FileInfo since this is used by mod_rewrite. This is accomplished by finding and editing your host configuration file. For virtual hosts this is likely to be located in:
/etc/apache2/sites-enabled/yourhostname.conf
Make sure the following line is included between <Directory> and </Directory>:

AllowOverride FileInfo


 

2)   .htaccess

The file .htaccess included with Wordpress should be sufficient, but in case you need to check the file it should look something like this:

# 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


 

3)   Wordpress


When the above criterias for Apache2 and .htaccess have been met, you can login to your Wordpress and activate Permalinks.
Settings -> Permalinks ...and set your preferred permalink structure.

This made permalinking in my Wordpress site so much more fun...


No comments:

Post a Comment