0

I am running codeigniter 3.1 in my localhost.

When I access my "Codeigniter" folder from localhost, it opens fine.

But when I change the folder name to "myProject", and try to access localhost/myProject or localhost/myProject/index.php it is showing "404 Page Not Found".

But when I tried to access localhost/myProject/index.php/Welcome it worked!

Nic3500
  • 8,144
  • 10
  • 29
  • 40
VikashSDNT
  • 41
  • 1
  • 6
  • 1. If you change the folder name back to "Codeigniter", everything is ok, isn't it? 2. Do you use .htaccess? – Nghi Ho Aug 24 '18 at 18:39
  • yes, when again i am renaming it to codeigniter it is working. I am using .htaccess with trying $config['index_page'] = ''; $config['base_url'] = ''; (in config.php) – VikashSDNT Aug 24 '18 at 18:43
  • Ok i got the actual problem. – VikashSDNT Aug 24 '18 at 18:45
  • When i am giving a space in project name like "my Project" it providing error, but "myProject" does not providing any error. Anyone know why? – VikashSDNT Aug 24 '18 at 18:46
  • Hope it help. https://stackoverflow.com/questions/497908/is-a-url-allowed-to-contain-a-space – Nghi Ho Aug 24 '18 at 18:57
  • @VikashSDNT Because leaving spaces in path names is for Windows dummies. Don't leave spaces for paths that are supposed to be referenced in a url, unless it's in a query string. – MarkSkayff Aug 25 '18 at 00:43

2 Answers2

1

Go to your codeigniter project

  1. open myProject

  2. open application

  3. open config then open config.php file.

  4. change your $config['base_url'] to $config['base_url'] = 'http://localhost/myProject/';

you need to set the base_url on your project folder name.

curiosity
  • 834
  • 8
  • 20
0

You can make dynamic base url also, once its done, then you will no need to chnage base url in config.php, even if you will upload your project on server, then will no need to change base url in config.php.

Please use this code, to make dynamic base url.

$root = (isset($_SERVER['HTTPS']) ? "https://" : "http://").$_SERVER['HTTP_HOST'];
$root.= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;

Thanks

Sorav Garg
  • 1,116
  • 1
  • 9
  • 26