Url parameters values with special characters are providing errors in view
Asked Answered
C

1

1

I have edited Url manager to provide SEO friendly urls but getting problem when the url have values with special characters such as . or () or - or any other special character

http://localhost/nbnd/search/city/delhi

In city action
var_dump($_GET);

output: array(1) { ["city"]=> string(6) "delhi" } 

but when url is with some special character
http://localhost/nbnd/search/city/north-delhi or
http://localhost/nbnd/search/city/north.delhi or
http://localhost/nbnd/search/city/(north)delhi

In city action
var_dump($_GET);

Output : array(1) { ["north-delhi"]=> string(0) "" } 
and so for other

this change in array values results in error.

Catenane answered 15/12, 2012 at 15:59 Comment(2)
what are the characters that you want to allow?Fendley
@Fendley i want all them it was working earlier with default url but it didn't work with SEO formatted urlsCatenane
F
2

As you want all sorts of characters, change your rule from the related question/answer:

'<controller:\w+>/<action:\w+>/<city>'=>'<controller>/<action>',
// omit the pattern \w+ from city:\w+

Documentation:

In case when ParamPattern is omitted, it means the parameter should match any characters except the slash /.

Fendley answered 15/12, 2012 at 16:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.