RegEx for CodeIgniter Routing

Posted on 2011-05-04
Last Modified: 2012-05-11

I need regex to filter certain type of urls and exclude some. The urls can be of type

I need regex to work if the first (anystring) is not one of these (cart|product|account|auth)

Question by:harvest-soft
    LVL 74

    Assisted Solution

    by:käµfm³d 👽
    $route['^(?!(?:(?:cart|product|account|auth)/))[^/]*/.*'] = ...

    Open in new window


    Author Comment

    Nope doesn't work.
    Let's simplify this. All I need is ['(:any)/(:any)'] to make sure the first (:any) is not cart|product|youraccount

    Accepted Solution

    Ok. I think I got it


    Author Closing Comment

    I accepted my comment as solution because it worked! Ofcourse kaufmed helped me. He takes 500 points :)
    LVL 74

    Expert Comment

    by:käµfm³d 👽
    Glad to have helped  = )

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now