I recently started using codeIgniter and I am stuck in a problem.
I’ve two files in my view folder
- index.php
- profile.php
When I go to the url http://localhost/php/ci/index.php/ it shows my index.php page and everything is fine.
But when I go to http://localhost/php/ci/profile.php/ it says
The requested url was not found on server.
Why is this happening what’s the problem ??
My Controller Files Names Are:
- home_control.php
- profile_control.php
home_control will interact with index.php and profile_control will interact with profile.php.
You have a fundamental flaw in your MVC understanding. The
index.phpfile sitting in your document root (that is, your www directory) is actually responsible for getting CodeIgniter started on every request. That is theindex.phpthat you are seeing in the URL bar.You are confusing said
index.phpwith theindex.phpthat you fabricated inside of theviewsfolder. Never will you be able to create a file inside of yourviewsfolder and be able to immediately access it using the URL bar. You must go through a controller.If you access
http://localhost/php/ci/index.php/profile_controlandcontrollers/profile_control.phpcontains::You will be able to see the contents inside of
views/profile.phpTo reduce confusion, it is essential that you read this before going forward.