Reputation: 337
For Security reasons as mentioned here http://codeigniter.com/user_guide/installation/index.html I have placed the system and application folders in another folder called OSW_appnsys, which is above the web root folder. Now I have a controller class called 'Pages' and a 'View' function in it in the following directory.
C:\wamp\www\OSW_appnsys\application\controllers
Now when I am calling the 'View' method of the controller 'Pages' from another view file called 'header.php' I am getting the 404 error like this
The requested URL /CodeIgniter_2.1.2/pages/view/products was not found on this server.
where product is the URI.
And I am calling this way:
<a class="mainmenu" href="<?php echo base_url('pages/view/products')?>">Products</a>
Any help will be highly appreciated. Ty
Upvotes: 0
Views: 14679
Reputation: 122
try this in anchor tag
base_url().'index.php/pages/view'
and load view products.php
in view function in Controller
Upvotes: 0
Reputation: 6394
It seems you may have understood how CodeIgniter works.
As above, within your configuration file, you will have
$application_folder = 'application';
$system_folder = 'system';
Change these to
$application_folder = '../OSW_appnsys/application';
$system_folder = '../OSW_appnsys/system';
Then point your browser to the URL of where the CodeIgniter's index.php exists.
i.e.
\
\OSW_appnsys
\OSW_appnsys\application
\OSW_appnsys\system
\htdocs
\htdocs\index.php
via
http://localhost/index.php
Also, when accessing controllers or views, you simply need to access the controller name. i.e.
<a href="<?php echo site_url('pages/view'); ?>">Go to page</a>
Then you would have a Page controller with a View action within which would do
<?php
class Pages extends CI_Controller {
public function view()
{
echo $this->load->view('pages/view');
}
}
?>
Upvotes: 1
Reputation: 657
You don't link to a view, you link to the name of a controller. If your controller is named 'Pages', you have to link to:
<a class="mainmenu" href="<?php echo base_url('pages/controllers/products')?>">Products</a>
Assuming that you have placed your controllers in a 'pages/controllers/' folder. In the controller named 'pages' you load the view (a file named products_view.php or something, which is in your views folder) like so:
$this->load->view('products_view.php');
Upvotes: 3