Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
routes.php case-sensitivity
  • Hello,

    I really feel like I should know this but I'm having issues.  I made some changes to my routes file and have found that my custom routes are not case insensitive.  In other words, 'hello(/:name)?' => array('welcome/hello', 'name' => 'hello'), will redirect to 404 if "/Hello/tony" is entered.  Auto detected routes, however, are properly processed.  So "/Welcome/HelLo" is correctly routed to Controller_Welcome action_hello.

    Is there a way to do this in the regex of routes.php or some such, that it might behave in the default fuel controller routing manner (ignoring case).

    Thanks,
    Tony
  • Found it:

    in config.php there is a 'routing' => 'case_sensitive' => true/false property which I missed.  ctrl + f in that file for "route" was coming up null.  My bad.
  • It is bad practice to switch this off. In general, users don't type in URL's themselfs, and the links in your application should have the correct case.
  • Thanks for the note Harro.  I'll consult with my boss - but I think it was a client requirement.  Something to do with making external links more attractive?  Another possibility I found was including code such as Router::add('hello(/:name)?', new Route('hello(/:name)?', 'welcome/hello', false));

    But I couldn't figure out the best place to place it - and it looked like a really bad idea.  If you have any suggestions of an alternative way I'm all ears, but I am fairly certain that it is a client requirement at this point in time :/.
  • HarroHarro
    Accepted Answer
    Clients... Why can't we just code without clients... :-)

    It's the main reason that config key is there in the first place, you're not the first with such a client...

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion