The pretty permalinks for wordpress can also be enable through apache config, which increases server speed.

Background

Most wordpress sites run with pretty permalinks turned on.  Typically this happens through a “.htaccess” file.  It’s also possible to integrate this through the config of apache.  On some hosting / servers using htaccess is disabled, in which case you may sometimes ask the support / admin to change something in the apache config.  Another reason to go this road is that by consciously disabling htaccess and using exclusively the webserver’s config file, is that this runs faster, as the server doesn’t need to look for a htaccess file in each subdirectory.

Code

<Directory “/<siteroot>/”>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</Directory>

Make sure to replace <siteroot> with your correct path.

You might notice this is very similar to what wordpress tells you to do or writes to a htaccess file.  That’s quite logical, as under the hood, both use rewrite rules.  The only difference is in telling the server when to apply these rules, via “<IfModule mod_rewrite.c>” in htaccess and via <Directory> in the apache config.

NOTE : this code needs to be implemented in EACH virtual host, as it includes a path specific to the respective website.