Home > PHP > Search Engine Friendly URLs using PHP

Search Engine Friendly URLs using PHP

A little while ago I wrote a post on Django Inspired SEF urls. I’ve since put together a working example and am now making it available for download.

There are a couple of things to note :

  1. You’ll need to edit the necessary path and url info found inside index.php and .htaccess
  2. The sample code inside index.php is for demonstration purposes only – I strongly recommend using a proper gateway/bootstrap interface typically found in MVC based systems such as Zend Framework and CakePHP (though they of course have their own SEF url implementations).
  3. Edit urls.php to play around with the regular expressions. I’ll be the first to admit that my regexp skills are not the best in the world, so if you notice something that will work better, please let me know – I’d really appreciate it
  4. I’ve included a url generator inside the class to try and make your life easier – view index.php for example usage

That should do it. You can download the script here.

Please play around with it and if you make any improvements I’d love to hear about it.

Categories: PHP Tags: , , ,
  1. February 3, 2009 at 8:03 am

    GEEZ!! Thanks for this… It really works! but I wonder if I want it on the index in the public_html how can I put it on the path both in .htaccess and on the index.php

    • February 3, 2009 at 9:31 am

      Hi Eneza, glad you found a use for the script.

      I’m not 100% sure what you’re trying to do, could you perhaps give an example ?

  2. June 15, 2010 at 9:37 pm

    nice post! thanx a lot bro!

  1. December 12, 2008 at 3:22 am
  2. December 12, 2008 at 4:23 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: