Welcome Guest, Not a member yet? Register   Sign In
space in url
#1

[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?
#2

[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 }
#3

[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
#4

[eluser]xwero[/eluser]
the function urldecode will change all %20s to spaces so it doesn't matter how many spaces are in the keyword.
#5

[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.
#6

[eluser]xwero[/eluser]
try to use the url_title function from the url helper
Code:
url_title($keywords)
this function was made especially for displaying random words in the url (post titles, keywords, ...) The only thing thing that you can't do is using operators and disallowed characters. If you want to do that i think it's best you put the keywords in a session variable and don't show it in the url.
#7

[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 !!!
#8

[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?
#9

[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

Severity: Warning

Message: preg_match() [function.preg-match]: Compilation failed: range out of order in character class at offset 18

Filename: libraries/Router.php

Line Number: 408

The URI you submitted has disallowed characters.
#10

[eluser]xwero[/eluser]
permitted_uri_chars regex
It's almost the same as Sarfaraz maybe the + at the end causes the error.




Theme © iAndrew 2016 - Forum software by © MyBB