Adding pretty-print URLs

Overview

Pretty-print URLs (permalinks) in WordPress transform meaningless URL patterns, e.g. index.php?page_id=123 into meaningful URLs, like /wordpress/adding-pretty-print-urls. Navigation is easier to view in the browser, plus it helps with SEO. Enabling pretty-print is a two-part process, add a few lines to your .htaccess and configure the display style in WordPress.

Permalinks before and after as seen in the browser.

Permalinks before and after as seen in the browser.

Solution

  1. Create a .htaccess file inside the document root for your WordPress site if it does not already exist.
  2. Add the following lines to the .htaccess file
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    • Files > File Manager works well for performing a quick edit on this file
  3. Login to your WordPress admin portal, typically /wp-admin, e.g. http://example.com/wp-admin
  4. Visit Settings > Permalinks to choose a permalink structure under Common Settings
    • we use a custom structure with the value /%category/%postname%/ since multiple categories could contain the same post title

      Custom permalink used on kb.apnscp.com.

      Custom permalink used on kb.apnscp.com.

  5. Click Save Changes

 

See also

Leave a Reply