1

Well I've been enjoying CodeIgniter for a few years now but I still haven't got the hang of using regexp in my URI routing in routes.php

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

For example:

http://mywebsite.com/http://www.google.com
http://mywebsite.com/www.google.com
http://mywebsite.com/google.com

the $_SERVER['REQUEST_URI'] is like: /http://www.google.com

I was using: $route['^(http.|www.)'] 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 http://example.com/file.txt to match.

If anyone could help with this expression I really would be very grateful. I've been losing sleep on this one!

TimFelix
  • 161
  • 1
  • 2
  • 8
  • Is this answer of any help? http://stackoverflow.com/questions/161738/what-is-the-best-regular-expression-to-check-if-a-string-is-a-valid-url Whatever you do, your regex is going to be enormously complicated. – PaulD Dec 22 '16 at 00:56
  • Perhaps this php function will help instead of regex? http://www.w3schools.com/php/filter_validate_url.asp – PaulD Dec 22 '16 at 01:00
  • go with this link https://www.codeigniter.com/userguide2/general/routing.html , https://www.codeigniter.com/userguide3/general/routing.html –  Dec 22 '16 at 06:28
  • thanks @aswad-shaik. i've read the docs again and again and still can't figure it out. Might have something to do with the way codeigniter handles periods in the uri. – TimFelix Dec 22 '16 at 07:17

0 Answers0