Pretty permalinks 404 error in Wordpress
For 2 days now I have been trying to get “pretty” permalinks working in Wordpress and all it has resulted in is the dreaded 404 Page Not Found. The reason im writing about this is in hope that it helps others who are pulling their hair out when trying to get this to work. The whole idea of this was to change the default “ugly” links (http://example.com/?p=N) to something alot nicer and more search engine friendly (eg. http://example.com/category/post-name/). This was supposed to be a painless process but for some reason it just would not work!
Well.. after a couple of days scouring countless blogs, checking file permissions, modules, .conf files, I finally got it running. First of all I had to check that apache was loading the mod_rewrite module. To do this you need to edit /conf/httpd.conf in your apache dir and remove the # in front of LoadModule rewrite_module modules/mod_rewrite.so. Secondly you need to ensure that .htaccess (in your wordpress dir) has the correct permissions so that WP can write to it (chmod 666 – remember to change this back to 644 when done).
Next you need to check your directory settings. If the AllowOverride directives are set to None, apache will ignore the .htaccess file (see Apache Docs). Now depening on whether you are running vhosts or not, you need to edit /conf/httpd.conf or /etc/httpd-vhosts.conf and add or change the following:
<Directory />
Options FollowSymLinks
AllowOverride FileInfo
</Directory>
Ok, now its time to enable custom permalinks. Go to Permalinks and select an option (or create your own). Once you have saved this check your .htaccess file in your WP dir. This should now read the default rules:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
If everything is set correctly your custom permalinks should now work. If not, then you are probably having the same problem I was having. My solution was very simple but took me 2 days to solve it. If you are running Apache on a Windows OS have a look at your .htaccess – see the -> . <- (dot) in front of htaccess. Well remove it so the file is just htaccess. Problem solved.













