SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru Angry Coder's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple routing issue (CodeIgniter question)

    Hello,

    I need my articles to be working directly through my domain:

    That why I have in my routing file:

    $route[':any'] = "article";
    But I have other controllers that I want to exclude.

    So my question is how can I exclude a list of controllers? I believe I should use Regular Expressions but I donít know how.

    Regular Expressions

    If you prefer you can use regular expressions to define your routing rules. Any valid regular expression is allowed, as are back-references.

    Note: If you use back-references you must use the dollar syntax rather than the double backslash syntax.
    A typical RegEx route might look something like this:

    $route['products/([a-z]+)/(\d+)'] = "$1/id_$2";
    In the above example, a URI similar to products/shirts/123 would instead call the shirts controller class and the id_123 function.

    You can also mix and match wildcards with regular expressions.
    http://codeigniter.com/user_guide/general/routing.html

    Your help would be greatly appreciated.
    Why It Doesn't Work?!

  2. #2
    SitePoint Addict skunkbad's Avatar
    Join Date
    Apr 2008
    Location
    Temecula, CA
    Posts
    278
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's not what you want, but it's more CI friendly to do something like this:

    $route['article/(.+)/([0-9]+)'] = "article/show/$2";

    which allows you to not cripple the rest of your CI.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •