space in url |
[eluser]JOKERz[/eluser]
i have url like this : http://localhost/ci/controller/function/...age_number when the keyword contain space like this: http://localhost/ci/news/index/key%20word/name/asc/2 why it return page not found?
[eluser]xwero[/eluser]
if you are searching for 'key word' in your controller you have to use urldecode Code: if(urldecode($this->uri->segment(3)) == 'key word'){ // do something }
[eluser]JOKERz[/eluser]
what if my keyword contain 3 word with space at all?? ex: $keyword = "this is keyword" so it should be: http://localhost/ci/news/index/this%20is...name/asc/2
[eluser]xwero[/eluser]
the function urldecode will change all %20s to spaces so it doesn't matter how many spaces are in the keyword.
[eluser]JOKERz[/eluser]
[quote author="xwero" date="1198691262"]the function urldecode will change all %20s to spaces so it doesn't matter how many spaces are in the keyword.[/quote] still return : 404 Page Not Found The page you requested was not found. i try to use str_replace(' ','_',$keywords) it works normal but when i use str_replace(' ','+',$keywords) it return The URI you submitted has disallowed characters.
[eluser]xwero[/eluser]
try to use the url_title function from the url helper Code: url_title($keywords)
[eluser]Sarfaraz Momin[/eluser]
You have to modify your config.php file in the application/config folder Code: $config['permitted_uri_chars'] = 'a-z 0-9~%.:_-+'; Good Day !!!
[eluser]JOKERz[/eluser]
ok, i will try all of your suggestion. but back to my case above. why when theres space or %20 in the url, ci sez page cannot be found? is something wrong with my script?
[eluser]JOKERz[/eluser]
[quote author="Sarfaraz Momin" date="1198695701"]You have to modify your config.php file in the application/config folder Code: $config['permitted_uri_chars'] = 'a-z 0-9~%.:_-+'; Good Day !!![/quote] i got this Code: A PHP Error was encountered
[eluser]xwero[/eluser]
permitted_uri_chars regex It's almost the same as Sarfaraz maybe the + at the end causes the error. |
Welcome Guest, Not a member yet? Register Sign In |