After setting up a self-hosted WordPress server, I changed the permalinks settings to display links using post name instead of the plain page ID format. This is important if you want better SEO functionality since search engines take into account the name.

image

Pretty links are much more descriptive and thus have better visibility in search engines. If you have a self-hosted WordPress server running Linux and Apache there are a couple of things you need to do to get pretty links to work out of box.

This first thing to do is make sure you disable any SEO or redirect plug-ins on WordPress if this is not an OOB instalaltion. Once we get pretty links working, you can enable the plug-ins one by one. This is to eliminate any conflicts that may be cause permalink pretty links to not work.

Open a command prompt on your Linux server ane install mod_rewrite for Apache if this is not already done. This package is necessary for pretty links to work.

sudo a2enmod rewrite

Next, navigate to  /etc/apache2/sites-available and look for the  .conf file for HTTP or HTTPS that relates to the Web site.  There may be more than one conf file in the directory.

image

The correct .conf file will display the Web site URL as shown below.

image

In our case it’s wordpress-le-ssl.conf. Open the file for editing

sudo nano wordpress-le-ssl.conf

Copy the code below and insert it into the .conf file.

<Directory "/var/www/YourSite"> 
Options FollowSymLinks AllowOverride All Order allow,deny Allow from all </Directory>

Replace /var/www/YourSite path (2) with the DocumentRoot path (1) 
You can find that path in the DocumentRoot line. In our case, our DocumentRoot path is /var/www/wordpress

image

After you save the changes, restart Apache using the following command:

sudo systemctl restart apache2

Enjoy your pretty links!
image

Leave a comment

Your email address will not be published. Required fields are marked *

error: Sorry, copy/paste is disabled
Skip to content