Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter 404 Page Not Found. (because of space character in project Url)
#1

(This post was last modified: 03-17-2015, 12:25 AM by Mamadex. Edit Reason: change the title of post )

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.
Reply
#2

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

(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?
Reply
#4

(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
Reply
#5

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).
Reply
#6

@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.
Reply
#7

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB