Press "Enter" to skip to content

Sticky Permalink Issue Solved Using .htaccess

When I had my blog setup with Yahoo Small Business Hosting, I had to make one compromise due to Yahoo’s restriction on the use of .htaccess file. When I set up “Permalinks” on WordPress, the best I could get was something like “http://example.com/index.php/my-blog-post”. I had to live with the “index.php” in all my Permalinks.

Now that I relocated my blog to another hosting service, I had to decide how to deal with this. I imported all my old  blog content to my new setup, and I also know that many sites have linked to many of my earlier articles. If I did not configure my new blog to also have “index.php” in the links, then all references to my older articles would fail. But now that I had a chance to really clean up the Permalinks, did I really want to continue to have “index.php” in them?

What I really needed was a way to support “index.php” to support all my legacy posts, and yet, not have “index.php” for all new content. Now that my new hosting service allows the use of .htaccess files, I was looking for some way to achieve this — and I found a way to do it!

In my WordPress Permalink setup, I chose the custom option to say “/%postname%/”. Then I added a line such as this to my .htaccess file in my WordPress installation directory:

Redirect /index.php/ http://blog.example.com/

That was it! Now if I insert a “index.php” in any of my content URLs, it gets ignored and all my new URLs look clean. So an older post can be accessed with or without the “index.php” in the path!

Share:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • Add to favorites
  • email
  • Google Buzz
  • MySpace
  • RSS
  • Slashdot
  • Technorati
  • LinkedIn

Be First to Comment

Leave a Reply