PHP Magic Book – Free PHP Scripts, Tutorials and Downloads, PHP AtoZ Reloaded, free php tutorials, free php downloads, php scripts, PHP tips

Redirect Ugly Permalink to Postname

Most of the blogs, even popular blogs have their permalink structure like:

http://www.yourblog.com/year/month/day/post-name/

WordPress Offers following permalink structures:

http://www.yourblog.com/?p=123 (Default)
http://www.yourblog.com/2008/11/10/sample-post/ (year/month/day/postname)
http://www.yourblog.com/2008/11/sample-post/ (year/month/postname)
http://www.yourblog.com/archives/123 (numeric)
and custom permalink structure

The recommended one by SEO experts is following:

http://www.yourblog.com/sample-post/

Which can be achieved by putting /%postname%/ in custom permalink box from your admin area under permalinks.

Many bloggers will not switch to recommended permalink because they have got backlinks for their old permalink. If you are still using the ugly /%year%/%month%/%day%/%postname%/ permalink structure, you should be interested to know how you can switch to the elegant /%postname%/ structure without loosing any backlink, using a simple .htaccess redirection.

The first thing to do is to change permalink structure from your admin area.
Go to Permalinks
Select custom
Fill out the field with /%postname%/

http://www.yourblog.com/post-name

Now we have got to redirect all backlinks using the old permalinks structure to the new permalink structure. To do so, you’ll have to edit the .htaccess file, located in WordPress installation root directory.

Paste the following line in your .htaccess:

RedirectMatch 301 /([0-9]+)/([0-9]+)/([0-9]+)/(.*)$ http://www.domain.com/$4

Congrats! You just changed your permalinks structure without loosing any backlinks! Cheers…

  • Share/Bookmark
Tags: ,
Posted in: Hacks, WordPress
Post's RSS » RSS 2.0
Post's Comments RSS » RSS 2.0

Related Posts




Post a Comment

  Subscribe Via RSS
  Subscribe Via Email