Welcome Guest, Not a member yet? Register   Sign In
Problem with routes.php and brackets
#1

[eluser]umbungo[/eluser]
When trying to re-route a name with brackets in it i get a 404. Is it possible to fix this / how?

Thanks.
#2

[eluser]umbungo[/eluser]
anyone? please?
#3

[eluser]osci[/eluser]
Not sure if it helps but check adding them in application/config.php at $config['permitted_uri_chars']
#4

[eluser]WanWizard[/eluser]
Route's are regex definitions, you can't just include characters in a route that have special meaning in a PHP regex. Like a bracket. Try escaping it with a backslash.
#5

[eluser]umbungo[/eluser]
hmm.. Thanks for the replies.. i tried both of these suggestions and no joy.

Would it only be the first half that needs escaping? eg..
Code:
$route['Name-With-\(Brackets\)'] = "main/main/Name-With-(Brackets)";
(NB: i tried various different combinations and none seemed to work)
#6

[eluser]umbungo[/eluser]
still stuck on this one
#7

[eluser]danmontgomery[/eluser]
Seems like it would be more appropriate to be using backreferences ($1, $2, etc) for parameters?
#8

[eluser]umbungo[/eluser]
AHHHHHHHHHHH finally.

Escaping the brackets does not work. I tried double/triple/quadruple escaping them too. After several hours staring at /trying to figure out /playing with the code trying to get things to work i finally got to the solution;
Code:
$route['Name-With-&\#40;Brackets&\#41;'] = "main/main/Name-With-(Brackets)";
$route['Name-With-&\#40;Brackets&\#40;/:any'] = "main/main/Name-With-(Brackets)/$1";
So thats HTML entity for brackets, IN DECIMAL, and not forgetting the escaping of #. Oddly (with my understanding, anyway), the HEX html entity encoding
Code:
'Name-With-&\#x28;Brackets&\#x29;'
does not work either.

note: I ******* HATE THESE ISSUES WITH CHARACTER ENCODING. How are you meant to tell what form it is deciding to take today? Almost impossible to debug too; echo anything in the browser and it comes out as normal text.




Theme © iAndrew 2016 - Forum software by © MyBB