Pretty Permalinks

Wordpress Permalinks

Follow Me!
FacebooktwitterlinkedinyoutubeFacebooktwitterlinkedinyoutube

It turns out that deciding on a permalink structure is not as straightforward as it seems it should be. A permalink is the permanent link to blog posts, pages, categories, etc. that you see in the URL box of the browser. What I thought would be a quick spruce-up of my site URL’s turned into a couple hours of research that I suspect will require some followup tweaking.

The WordPress default (otherwise known as ‘ugly’) for the permalink structure is:

http://example.com/?p=N

where N is the WordPress generated post number and the ? is used by PHP to send variables through the URL string. So, until I changed it today, the url for any one of my posts would be something like:

https://iamlamiak.com/?p=242

NOT so pretty and not SEO friendly.

Rather than using the ‘almost pretty’ permalinks, which would require that /index.php be inserted in the URL structure ie:

https://iamlamiak.com/index.php/year/month/postname

I opted to have a complete makeover and use the ‘pretty permalinks’ which give many, cleaner structure options.

Pretty permalinks require an Apache server with the mod_rewrite module and an .htaccess file in the root directory of your hosting server containing the following code:

# BEGIN WordPress

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

# END WordPress

As far as I can tell (from endless Google searches), this is the most recent .htaccess code (as of WP 3.0) including the new line of code:

RewriteRule ^index\.php$ – [L]

This line cleans up the index.php end of the URL not handled by Apache’s mod_rewrite, which is a subject for another post! Suffice to assume it improves script optimization and SEO.

A point to keep in mind: if your site is in a subdirectory the following code would change:

RewriteBase /subdirectory/
RewriteRule . /subdirectory/index.php [L]

Once you’ve got the .htaccess file all set you need to enter your structure choice in the Settings → Permalinks panel → Custom Structure Field using the structure tags.

Of course, I can’t simply choose a default and just GO with IT…I thought I’d just Google ‘optimal permalinks’ and opened up a can of permalinks. For more (and …more) information on setting up the optimal custom permalink string check out this post on Otto on WordPress: Category in Permalinks Considered Harmful: Do NOT start your permalink with %postname%, %category%, %tag%, or %author%


Please Share!
FacebooktwitterpinterestlinkedinFacebooktwitterpinterestlinkedin

Leave a Reply

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

Connect with Facebook