Welcome Guest, Not a member yet? Register   Sign In
How to make codeIgniter as SEO url friendly
#1

[eluser]Unknown[/eluser]
Code:
CREATE TABLE IF NOT EXISTS `url_alias` (
  `pid` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'A unique path alias identifier.',
  `source` varchar(255) NOT NULL DEFAULT '' COMMENT 'The Drupal path this alias is for; e.g. node/12.',
  `alias` varchar(255) NOT NULL DEFAULT '' COMMENT 'The alias for this path; e.g. title-of-the-story.',
  `language` varchar(12) NOT NULL DEFAULT '' COMMENT 'The language this alias is for; if ’und’, the alias will be used for unknown languages. Each Drupal path can have an alias for each supported language.',
  PRIMARY KEY (`pid`),
  KEY `alias_language_pid` (`alias`,`language`,`pid`),
  KEY `source_language_pid` (`source`,`language`,`pid`)
)


Create a table like the above

alias: field says the normal browser url like http://praveenkumar.org/ci/code-igniter-seo.html

in this field we make a entry like ci/code-igniter-seo.html

When the user enter this url in the browser direct the system to router.php in CodeIgniter there create a function with returns the actual controller/action path

Code:
function return_url($alise){
   $sql = "select source from url_alise where alias ='$alise'";
   mysql_query($sql);
   .............

   return $source;//if there is no url return false
}


If there is no perfect match with the table follow the normal work flow of CI. If still there is no match page it will direct to 404 page with appropriate design.








Theme © iAndrew 2016 - Forum software by © MyBB