Various

WordPress permalinks resulting in HTML Error 404

Posted on

For all of you who are trying to get a wordpress with permalinks up and are running into html 404 errors when opening a page or category … well I did … so check out the following settings and make sure they are correct. Please notice that some settings in this post may be specific to debian and may differ from your installation with another distribution.

Apache2 Site Settings

Make sure you have set “FollowSymLinks” & “AllowOverride All” in your apache2 site. You can find your enabled sites in your apache2 configuration directory, e.g. in debian it is /etc/apache2/sites-enabled. Without the “AllowOverride” setting apache2 will ignore the necessary .htaccess file.

apache2_site_settings
Apache2 site settings

 

Apache2 activate rewrite mod

Be sure to activate the rewrite mod from apache2. If it is enabled you will find it in /etc/apache2/mods-enabled.

apache2_mod_rewrite
Apache2 Enabled Mods

 

If you don´t find it there, but you can find it in /etc/apache2/mods-available the mod is not enabled and you can enable it with the following commands:

  • a2enmod rewrite
  • service apache2 restart

You can make sure it is loaded correctly by the apache2 server if you have a look in your php settings. Place a php file (e.g. info.php) with the following code on your webserver and call it with your browser.

PHP Info loaded apache2 modules
PHP Info loaded apache2 modules

.htaccess in wordpress root folder

WordPress should automatically create a .htaccess file in your wordpress root folder. If it isn´t there wordpress might have some permission problems to create the file. Per default the root user owns all files in /var/www but wordpress is running with the default user “www-data” as apache2 is running with this user. You have two possible ways to create the .htaccess file:

  • Give temporary rights to “www-data” to create files in /var/www or create an empty .htaccess file and give temporary write rights to “www-data” to fill it with data after you (re)enabled permalinks in wordpress
  • Manuelly create the file with the following content
 

Maybe these steps were helping you in finding the error with wordpress permalinks …