Fixed URL matching.

There was errors in substr, dirname and strpos functions.