In the new versions of WordPress it is possible to change the format of the permalinks. By default the permalinks are basically made up of a number (“?p=number”) and they don’t look so nice, but you can change them to contain the name of the post for example, the date of the post or they can even have some custom structure:
There are mainly two reason why people wish to switch from the default permalink structure to another one:
The best practice is to change the permalink format to the desired one immediately after a WordPress blog is created, however authors tend to change their mind, so the question is how to change the format when there are already some existing posts in the blog without losing the existing links (without getting broken links). Normally this should be as easy as choosing a new permalink format and telling WordPress to use it. Normally WordPress should take care of the old links and everything should be fine. Unfortunately this is not always the case because this behavior depends on the settings of the server which is hosting the WordPress blog. If the settings are not correct, you will get the “404 Not Found” error when you click a previously existing link after changing the permalink format. This means that after switching to the new format, you will need to update some settings on your server.
1. Log into your WordPress blog and go to Dashboard. After that go to Settings / Permalinks.
2. Select the desired permalink format and click “Save Changes”.
3. On your Raspberry Pi open a command window.
4. Edit the file /etc/apache2/sites-available/default:
- nano /etc/apache2/sites-available/default
- find the following two sections:
Options Indexes FollowSymLinks MultiViews
allow from all
- Put a “+” sign in front of the “FollowSymLinks” strings and change the “AllowOverride None” lines to “AllowOverride All”. So after the change the two sectios should look like this:
Options Indexes +FollowSymLinks MultiViews
allow from all
- Save the file (CTRL+O)
5. Repeat the actions from step 4 for the file /etc/apache2/default-ssl
6. Copy some modules from the /etc/apache2/mods-available directory to the /etc/apache2/mods-enabled directory, in order for Apache to be able to use these modules:
- cp -p /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled
- cp -p /etc/apache2/mods-available/expires.load /etc/apache2/mods-enabled
- cp -p /etc/apache2/mods-available/headers.load /etc/apache2/mods-enabled
Note: The last two modules are only required if you are changing the permalinks because a caching plugin needs it. Otherwise the first module (rewrite) will suffice.
7. Restart Apache:
service apache2 restart