Installing the CI framework under Windows

Source: Internet
Author: User
Tags codeigniter

CI Framework is a very popular MVC framework, how to install and use CI Framework, in the CI Chinese network has been described in more detail, here to record the next few places to note.

First, the problem of index.php

Unzip the package download to the project root to run the demo inside. According to the first example of the CI Handbook, access the index method inside the welcome controller via controllers, just run http://localhost/CodeIgniter-3.0.6/index.php in the browser (where CodeIgniter-3.0.6 for the CI framework can be customized)

The URL here does not have a controller welcome because the default routing configuration is written in config/routes.php: $route [' default_controller '] = ' welcome ';

Then, when running the second example, application/controllers/pages.php,

In the address bar has been input is: http://localhost/CodeIgniter-3.0.6/pages/test/and Http://localhost/CodeIgniter-3.0.6/pages/test/about found that the error is not Found The requested url/codeigniter-3.0.6/pages/test/about is not Found on this server.

Directory:

controllers/pages.php:

<?PHPclassPagesextendsCi_controller { Public functionTest$page= ' Home 'The {///parameter can be used as a route, for example: Http://localhost/CodeIgniter-3.0.6/pages/test/about will jump to the About pageif(!file_exists(APPPATH. ' Views/pages/'.$page.‘. Php) ) {show_404 (); }        $data[' title '] =Ucfirst($page); $this->load->view (' pages/').$page,$data); }  } ?>

home.php

<? PHP Define dirname (__dir__)); require_once (Viewpaths. ' /template/header.php '); Echo "Hello home page." ; require_once (Viewpaths. ' /template/footer.php '); // __dir__  Gets the folder where the current file is located//dirname (__dir__)  gets the top level directory of the folder where the current file is located

header.php

Echo $title Echo $title;  ? >

footer.php

<div><em>&copy; 2016</em></div></body>

Think of what needs to be configured, and then see the route that block when you find that you need to enter [Your-site-url]index.php/pages/view] in the browser.

Need to join index.php too pit.

How to get rid of this index.php in the URL, search on the Internet under a few methods.

1. Need to open Apache's rewrite

A. Find LoadModule rewrite_module modules/mod_rewrite.so remove the front #

B. Find <directory "D:/my/develop/apachedev" > Change the allowoverride none inside to allowoverride all (requires restarting Apache)

2. Create a new. htaccess in the same directory as index.php.

Input content:

Rewriteengine on
Rewritecond $!^ (index\.php|images|js|css|robots\.txt)
Rewriterule ^ (. *) $/codeigniter-3.0.6/index.php/$1 [L]

Where CodeIgniter-3.0.6 can be completed according to the actual directory

This will allow you to access the controller directly after you restart Apache.

Http://localhost/CodeIgniter-3.0.6/pages/test Access OK

Http://localhost/CodeIgniter-3.0.6/pages/test/about Access OK

Reference Documentation:

Http://codeigniter.org.cn/user_guide/tutorial/static_pages.html

Http://www.php1.cn/article/7601.html

Installing the CI framework under Windows

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.