WordPress, Permalinks and 404 errors

This page has the permalink /2010/04/wordpress-permalinks-and-404-errors But internally its default URL is /?p=1495.

Permalinks help people see the topic of a page before it’s visited and generally mean that search engines will rank them higher too.

OK, so you’re getting 404’s as soon as you enable permalinks other than the default?

Firstly, make sure mod_rewrite is loaded. The easiest way is to use the phpinfo() function. This can be done by creating a php file containing the following code:


You can then check the output of the phpinfo() function to see if ‘mod_rewrite’ in enabled.

If mod_rewrite is not enabled, you will need to enable it on the command line by typing:

a2enmod rewrite

You’ll then want to restart apache with

/etc/init.d/apache2 restart

If this doesn’t fix the problem, browse to the root of your website and check if the file ‘.htaccess’ exists.
If it doesn’t, create one by typing

touch .htaccess

Make sure the .htaccess file is writeable with

chmod 755 .htaccess

If it’s still not working, check your apache config files. The root directory of your website must have AllowOverride set to all. For example, in the file /etc/apache2/sites-available/sitename

<Directory /srv/www/>
	AllowOverride All

Just make sure the AllowOverride is set to All. The other items should stay the same.

Restart apache and hopefully your 404 errors will be gone.

Tell me how it goes…..

You May Also Like

About the Author: John

Leave a Reply

Your email address will not be published. Required fields are marked *