CodeIgniter Forums
CodeIgniter 404 Page Not Found. (because of space character in project Url) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: CodeIgniter 404 Page Not Found. (because of space character in project Url) (/showthread.php?tid=1507)



CodeIgniter 404 Page Not Found. (because of space character in project Url) - Mamadex - 03-16-2015

Hello
I'm using CodeIgniter 3. on Windows, PHP 5.6.

The project in this path will not show because of the space (%20) between "My" and "Projects"!
Code:
http://127.0.0.1/My Projects/ci/
and displays the 404 Page Not Found (The page you requested was not found.)
But
Code:
http://127.0.0.1/My_Projects/ci/
url solves the problem.


RE: CodeIgniter 404 Page Not Found. (because of space character in project Url) - Avenirer - 03-17-2015

Why would you have a space in your url? All folder names and file names inside your localhost server should be named without space.


RE: CodeIgniter 404 Page Not Found. (because of space character in project Url) - Mamadex - 03-17-2015

(03-17-2015, 03:16 AM)Avenirer Wrote: Why would you have a space in your url? All folder names and file names inside your localhost server should be named without space.

Is it a law or something like convention?


RE: CodeIgniter 404 Page Not Found. (because of space character in project Url) - Avenirer - 03-17-2015

(03-17-2015, 04:58 AM)Mamadex Wrote:
(03-17-2015, 03:16 AM)Avenirer Wrote: Why would you have a space in your url? All folder names and file names inside your localhost server should be named without space.

Is it a law or something like convention?

It's not a law, but a convention. Tongue


RE: CodeIgniter 404 Page Not Found. (because of space character in project Url) - mwhitney - 03-17-2015

It's part of the specification for URIs: https://tools.ietf.org/html/rfc3986#section-2

The permitted characters are listed in 2.2 (Reserved Characters) and 2.3 (Unreserved Characters).

Spaces are not permitted characters in a URI, so they must be percent-encoded. Many browsers will convert them automatically (so "My Projects" would become "My%20Projects"). It looks like your server, for whatever reason, decided to replace the space with an underscore (maybe CI does this, I don't know; the url_title function certainly will when given '_' as the second argument).


RE: CodeIgniter 404 Page Not Found. (because of space character in project Url) - Mamadex - 03-17-2015

@mwhitney: Although my browser changes the URL space to '%20' (http://127.0.0.1/My%20Projects/ci/) in the background but CI still gets 404. then I changed the folder name manually to "My_Projects".

Any way thanks for reply.


RE: CodeIgniter 404 Page Not Found. (because of space character in project Url) - CroNiX - 03-17-2015

Most likely CI isn't converting the %20 entity back into a space. It's just best to never use spaces in file/dir names. No OS really likes it. You end up having to put quotes around paths with spaces in them, etc., and different OS's have different means to do that. So if you want consistency across platforms, just don't use spaces and it will work everywhere.