CI URI effectively delete index.php (Perfect CI Handbook)

Source: Internet
Author: User
Tags server error log

Adhering to the idea of the MVC architecture, all controllers in CI need to be loaded with a single point of entry file index.php (default) to load the call. That is, by default, all CI development projects have URLs that are in the form of the following:

Http://localhost/index.php/welcome obviously, by default, the presence of index.php in the URL address segment affects the simplicity of the URL and the SEO. We can get rid of this nasty index.php by the method described in the article below.

You may have noticed that there is already a workaround for this issue in the CodeIgniter user manual. But the official offer of this. htaccess configuration, not all the time to solve the problem. The following through the author debugging procedures for everyone to share:
Premise: The server configuration uses Apache as the Web server.

1. Copy and save the following configuration information as a. htaccess file (the. htaccess file is placed in the root directory, which is the sibling of the application directory),

By default, the index.php file will be included in your URL:

example.com/index.php/news/article/my_article

You can easily remove it by using the. htaccess file to set some simple rules.

-----------------------------------------------------------------

Rewriteengine on
Rewritecond%{request_filename}!-f
Rewritecond%{request_filename}!-d
Rewritecond $!^ (index\.php|images|robots\.txt)
Rewriterule ^ (. *) $/index.php/$1 [L
-----------------------------------------------------------------

Note: If your project is not in the root directory, please change the above sentence to: rewriterule ^ (. *) $ index.php/$1 [L] In the above example, any non-index.php, images, and robots.txt HTTP requests can be directed to index.php.

(The first step is the same as in the CI operation manual)

2, after the completion of the modification we visit the CI default welcome page ( Http://localhost/welcome ), an error will be , the error message is as follows:

--------------------------------------------------------------

Internal Server Error

The server encountered an internal error or misconfiguration and is unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything yo U might has done so may has caused the error.
More information on this error is available in the server error log.

--------------------------------------------------------------------------------------

I looked down here all the things on the website is such an error, that is, the picture and TXT can not open, and then look at the program found there are three files. htaccess, Httpd.ini, Nginx.conf, I think it should be these guys in the mischief, the first thought is. htaccess This distribution file, delete it, decisively open the site, then find the reason, the deleted to get back, to Apache Open. htaccess, here is how to open:

Found in Apache config file httpd.conf

Options FollowSymLinks
AllowOverride None

Some versions are written like this.

Options followsymlinks execcgi Indexes
AllowOverride None

Anyway, all you have to do is put the following

allowoverride None change to allowoverride all

And then you find

LoadModule Rewrite_module modules/mod_rewrite.so

Remove the "#" number from the front, remove the comment, and restart Apache. It's done!

CI URI effectively delete index.php (Perfect CI Handbook)

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.