CodeIgniter Forums
URI routing regexp - Printable Version

+- CodeIgniter Forums (
+-- Forum: Using CodeIgniter (
+--- Forum: General Help (
+--- Thread: URI routing regexp (/thread-66949.html)

URI routing regexp - timfelix - 12-21-2016

Hi there.
Well I've been enjoying CI for a few years now but I still havent got the hang of using regexp in my URI routing in routes.php
I was hoping for a bit of help if possible.

I am trying to route all requests for URI's that contain another URL.
For example:

the $_SERVER['REQUEST_URI'] would be like:

I was using:
but this doesn't catch the 3rd example

I'm wondering if I should either use one of those very long regexp's that look for a valid url and allow for the proceeding forward slash.

Another idea was to look for a period ('.'), But I didnt want to match.

If anyone could help with this expression I really would be very grateful. I could even send a few dollars. I've been trying to fix this for days (and nights)


RE: URI routing regexp - PaulD - 12-21-2016

I posted a couple of links for you on your stack overflow question that 'might' help (although probably not TBH). May I ask why you are trying to deal with such horrible urls? Could you not format the urls to be a bit more useable in some way or are you not in control of them. (Like

RE: URI routing regexp - timfelix - 12-21-2016

Hi there.
Thanks for your reply and the links you posted on stack overflow.
Yes, it does seem pretty horrible.
The uri is entered by a user into the browser address bar so i cant really change that.
my challenge is how to recognize that a user is adding another url onto the end of my url, regardless of whether they include the http, www, etc.