php - Codeigniter tutorial static page.. using Bitnami WAMP
Am trying Elisa Labs CodeIgniter tutorials. But am stuck with the first lesson itself. Ref: https://www.codeigniter.com/user_guide/tutorial/static_pages.html
As mentioned in the code I've created the controller and view. But I'm not able to view them in the browser as localhost/index.php/pages/view . I get 404 error. I'm using Bitnami WAMP. I get the default codeignitor welcome page at localhost. How can I access the newly created controller and view?
Please can any one help me with this?
More Details.
Content of C:\Bitnami\wampstack-5.4.25-1\frameworks\codeigniter\conf\httpd-prefix.conf
# Alias /codeigniter/ "C:\Bitnami\wampstack-5.4.25-1/frameworks/codeigniter/htdocs/"
# Alias /codeigniter "C:\Bitnami\wampstack-5.4.25-1/frameworks/codeigniter/htdocs"
# Alias /test "C:\Bitnami\wampstack-5.4.25-1/frameworks/codeigniter/htdocs"
# Alias /test/ "C:\Bitnami\wampstack-5.4.25-1/frameworks/codeigniter/htdocs"
DocumentRoot "C:\Bitnami\wampstack-5.4.25-1/frameworks/codeigniter/htdocs"
Include "C:\Bitnami\wampstack-5.4.25-1/frameworks/codeigniter/conf/httpd-app.conf"
Content of C:\Bitnami\wampstack-5.4.25-1\frameworks\codeigniter\application\controllers\pages.php
class Pages extends CI_Controller {
public function view($page = 'home')
{
if ( ! file_exists('application/views/pages/'.$page.'.php'))
{
// Whoops, we don't have a page for that!
show_404();
}
$data['title'] = ucfirst($page); // Capitalize the first letter
$this->load->view('templates/header', $data);
$this->load->view('pages/'.$page, $data);
$this->load->view('templates/footer', $data);
}
}
Answer
Solution:
I recently ran into the same issue, and discovered the solution after tinkering for some time. Bitnami's WAMP stack is configured to start in Apache's default web folder. Additional applications and frameworks can be added on to the stack as Bitnami apps.
The Bitnami configuration is located in:
<path_to_WAMP>\apache2\conf\bitnami
In this directory, there is a file namedbitnami-apps-prefix.conf
which contains the paths to all enabled applications.To get codeigniter working, I made two changes:
1) I added the following line to the file,
bitnami-apps-prefix.conf
:Include "<path_to_WAMP>/frameworks/codeigniter/conf/httpd-prefix.conf"
; and2) Since I was too lazy (and also a scared newbie) to alter Apache configurations, I created a shortcut:
<path_to_WAMP>\apps\codeigniter
that points to<path_to_WAMP>\frameworks\codeigniter
That's all it took to get the codeigniter examples running