News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Brandon Beasley's Blog:
Codeigniter Vanity URLs
September 16, 2010 @ 13:49:01

On his blog Brandon Beasley has a new tutorial for CodeIgniter users out there on how to create "vanity URLs" that are correctly handled by the framework's routing system.

Recently I worked on a CodeIgniter project that needed the ability to use vanity URLs and display stats about the user represented by the URL. For instance, suppose you want to pull all public data on a user from Twitter and display it within your web application on a customized URL such as http://mytwitterapp.com/brandonbeasley . The difficulty arose when the AUTO setting for URI protocols seemingly failed to handle the PATH_INFO protocol needed for Twitter callbacks and the REQUEST_URI protocol needed for vanity URLs.

His solution combines custom routing on the framework side and a bit of a change to the .htaccess to make the APP_PATH functionality work correctly. Then a simple controller can be created (in his case "User") and the username can be pulled in via the URI helper's segment() function. There's other ways to make this happen with the custom routing CodeIgniter offers, but this method allows for a more fine-grained approach.

0 comments voice your opinion now!
codeigniter vanity url tutorial htaccess apppath


blog comments powered by Disqus

Similar Posts

PHPFive.net: Creating a dynamic Google sitemap using the PHP5 SimpleXML extension

PHPBuilder.com: Using the PEAR Pager Package to Paginate MySQL Results

Fabien Potencier's Blog: Create your own framework...on top of the Symfony2 Components (parts 3 & 4)

Zend Developer Zone: Zip-it or DIY Tar-balls

NETTUTS.com: Build Your Own Captcha and Contact Form


Community Events





Don't see your event here?
Let us know!


version community security opinion composer framework interview release language laravel podcast introduction symfony library voicesoftheelephpant update mvc series package tool

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework