Home > PHP > Simple Clean URL Function in PHP

Simple Clean URL Function in PHP

October 15th, 2009 Wawan Leave a comment Go to comments


When u want to make permalink or clean url in your website, u will need function code that will encode your link to that (except u using CMS :D ). The example for clean url > from http://www.myweb.com/a=post&b=1 become http://www.myweb.com/post/1 its more beauty and more friendly to search engine. Beside using this function u can using it with .htaccess and some mod_rewrite engine in Apache. U can see in my other article for that :D . Lets see my simple code is :

/* clean url */
function permalink($stringurl) {	
	$url=parse_url($stringurl);	
	$strurl = basename($url['path'],".php").".";
	$qstring = parse_str($url['query'],$vars);
	while(list($k,$v) = each($vars)) {
		$strurl .= $v.".";
		}	
	$strurl .= "html";	
	return $strurl;
	}
Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • BlinkList
  • Live
  • MSN Reporter
  • MySpace
  • RSS
  • StumbleUpon
  • Technorati
  • Twitter
  • Yahoo! Bookmarks
Categories: PHP Tags: , , , , ,
  1. No comments yet.
  1. No trackbacks yet.