Contents Magic

Friendly URLs In WordPress

May 20th, 2007 ·

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

ok, let me admit. A while back I hardly had any ambition of making money from my blogs. Though I was not getting any search hits in the first place and on top of that I had no ads in my blog, but when I see the way other blogs are configured, it inspired me to go ahead and make my blog better then theirs, for myself and for my readers.

So one of the things that push me to use some of my time on week ends, was those better looking urls in a number of blogs. When I installed wordpress, my articles had a permalink looking something like

http://www.tanamtechnologies.com/wordpress/?p=[post_id]

All WordPress needs to fetch a post from my database is the execution of correct file [which is index.php] and supplying that file with the correct argument, which happens to be the post_id supplied with argument p. Clearly this is not very pretty. This is why they call the default permalinks as “Ugly”.

So I decided to make my url a little prettier, and alternatively, more accessible to search engine .

The first thing I did to was to Google friendly urls in wordpress

and two articles I found interesting were http://www.eplace.gr/google-seo-advice/make-wordpress-friendly-urls.html
and http://www.gnc-web-creations.com/wordpress-urls.htm. The second one isn’t great, but the first one was good enough to give me a good start.

It tells you how to use admin panel to change permalink option. As I told you, it was only a start. As I mad the the change it actually made things worse for me as the new urls wont work. and all I get after switching to the new url was a 404. Clearly the article was not complete. May be it worked for the guy who wrote it , but not for me.

It was not very difficult to find what was wrong. Obviously the my machine was not able to find new urls. This seemed like very obvious why wordpress would make a mistake of providing incomplete functionality. Somehow that was the way it was. WordPress did supplied something to make it work , but something was missing. I resorted to wordpress documentation, which anyone should do in the first place before actually doing a Google search.

It turns out that they do supply an .htaccess file to be used by mod_rewrite of apache. But the the file that I had was not modified by wordpress , as I would presume it would have been to accommodate the new urls. So I had to do it myself.

As I did that I while back, you can see in my post getting mod_rewrite rewriting , I had already gained some knowhow how to use mod_re-write, I set myself to make it work for the new urls.

So after a little experimentation in the httpd.conf of my Apache I was able to settle with the following, well, for at least a while.

RewriteRule ^/wordpress/(\d*)/(.*)$ /wordpress/index.php?p=$1 [P]

Now if a search engine indexes the new url or some one else starts linking to the post using new url, you cant change it. Should I decide to use any newer url format, then I must still support the old one somehow so that I don’t break the links coming to me.

Browse more posts marked in:

;

2 responses so far ↓ I do follow BTW
  • 1 Estercita // Jun 24, 2007 at 5:13 pm

    Your blog is simple, easy to use, easy to read. I like it. I ran into it looking for more info on the Pakisatany dancer by doing a google search. I’m VERY happy you posted that up.

  • 2 John Doe // Jun 24, 2007 at 7:06 pm

    Many Thanks Estercita, keep visiting and keep refering my place to your friends. You will find my perspective on many interesting topics in near future.

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>