Contents
If you decide you want to change the default permalink in WordPress you might encounter 404 errors getting to your posts and pages. This guide is intended help you though the process.
Select your Permalink style
Select your permalink style from the menu after logging into the wp-admin console. No doubt you already did this and that is what got you to this how-to guide.
Check the .htaccess file
Check that your .htaccess file looks correct
sudo cat /var/www/html/.htaccess
It should look something like the following
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
Enable Modrewrite
Now, we need to activate mod_rewrite
.
sudo a2enmod rewrite
Enable the use of .htaccess
By default the apache does not honor the .htaccess file so you will need to modify the apache configuration.
sudo nano /etc/apache2/apache2.conf
look for for the following lines in the file and change
# from <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> #to <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride FileInfo Require all granted </Directory>
This will allow apache to use the .htaccess file.
Restart Apache2
restart apache
sudo service apache2 restart
You should be good to go with your new permalink on your site
More Information
More information on setting WordPress with permalinks can be found here.