Apr
22
2010

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:

1
2
3
<?php
phpinfo();
?>

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:

1
a2enmod rewrite

You’ll then want to restart apache with

1
/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

1
touch .htaccess

Make sure the .htaccess file is writeable with

1
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

1
2
3
<Directory /srv/www/>
	AllowOverride All
</Directory>

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…..

Written by John in: Linux Tips |

No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment