Configuring permalinks with wordpress in a subfolder

In this post we will explain how to configure your web server in order to enable WordPress permalinks. A lot of people encounter errors, usually error 404, and then error 500 before it finally works. So let’s recap how to configure your server and WordPress !

internet errors

First go to your WordPress admin panel in Settings->Permalinks, select your wanted permalinks style and save. If a banner tells you to manually modify your .htaccess because WordPress can’t do it, connect to your server and copy the contents displayed in your .htaccess.
This file should be in the folder corresponding to the ‘URL adress’ of your website. This is the same as your WordPress installation folder only if you installed WordPress to your root folder. See http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory for more info.
Error 404 happens when you try to reach a page that doesn’t exist. It means that your server does not even understand the permalink format. This is due to a failing rewrite engine. You should take two steps from there :

  • Ensure that the rewrite engine is installed (this depends on your hosting service), use sudo a2enmod rewrite to install it.
  • Allow the engine for your website. Open the file /etc/apache2/sites-available/default and look for lines
     Options Indexes FollowSymLinks MultiViews 
                    AllowOverride None
                    Order allow,deny 
                    allow from all 

    Change AllowOverride None to AllowOverride All.

  • Restart your server with /etc/init.d/apache2 restart

It should now be working perfectly ! If you get a 500 error, make sure your .htaccess contents look like:


 RewriteEngine On
 RewriteBase /
 RewriteRule ^index\.php$ - [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /index.php [L]
 

Apparently many people pretend that the installation folder of your wordpress should be in there somewhere, but in our case it wasn’t required, and I would be curious to have feedback from people that do need it.

Sources:
Agence CSV
WordPress