How to make SEF URL

Discussion in 'PHP' started by ivan.kristianto, Oct 8, 2010.

  1. #1
    ivan.kristianto, Oct 8, 2010 IP
  2. HuggyEssex

    HuggyEssex Member

    Messages:
    297
    Likes Received:
    4
    Best Answers:
    2
    Trophy Points:
    45
    #2
    HuggyEssex, Oct 8, 2010 IP
  3. YoGem

    YoGem Active Member

    Messages:
    676
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    90
    #3
    For my custom CMS I use something like this:

    .htaccess file
    
    Options +FollowSymlinks All -Indexes
    RewriteBase /
    RewriteRule ^([a-z]+)/(.*) index.php?co=$1&op=$2 [NC]
    
    Code (markup):
    Practically I divide the string in two parts, the first one that I will call here co - command and a second one that I will call op - option, the two separated by a slash so I will have http://mydomain.com/command/option or http://mydomain.com/blog/title-alias

    Now the PHP part of it

    PHP
    
        $command = strip_tags($_GET['co']); // this will be the command
        $option = strip_tags($_GET['op']); // this will be the option
    
    Code (markup):
    Useless to tell you that now the choice is your on how to manage the datas acquired. :) hope it will help
     
    YoGem, Oct 8, 2010 IP