CIURI effectively deletes index. php (improved CI manual)

Source: Internet
Author: User
Tags server error log
CIURI effectively deletes index. php (improved CI manual). adhering to the idea of MVC architecture, all controllers in CI need to load and call through the single point of entry file index. php (default. That is to say, by default, the URLs of all CI development projects are in the following format:

Http: // localhost/index. php/welcome obviously, by default, the existence of index. php in the URL segment affects the URL conciseness and SEO. We can remove this annoying Index. php through the method described below.

You may have noticed that there is a solution to this problem in the CodeIgniter User Manual. However, this. htaccess configuration officially provided does not solve the problem all the time. The following describes the procedure of debugging:
Premise: The server uses Apache as the Web server.

1. copy and save the following configuration information as a. htaccess file.(The. htaccess file is placed under the root directory, which is the same as 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 use the. htaccess file to set some simple rules to delete it.

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

RewriteEngine on
RewriteCond % {REQUEST_FILENAME }! -F
RewriteCond % {REQUEST_FILENAME }! -D
RewriteCond $1! ^ (Index \. php | images | robots \. txt)
RewriteRule ^ (. *) $/index. php/$1 [L
-----------------------------------------------------------------

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

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

2. after the modification is complete, visit the CI default welcome page (Http: // localhost/welcome), An error is reported.The error message is as follows:

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

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, admin@sky00.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.

Bytes --------------------------------------------------------------------------------------

I have read everything on this website and reported an error, that is, the image and TXT cannot be opened. then I checked the program and found that there are three files in it. htaccess, httpd. ini, nginx. conf. I think these guys are playing tricks. The first thing that comes to mind is. delete the htaccess distribution file and open the website. find the cause, find the deleted file, and enable it in apache. htaccess is enough. The following is how to enable it:

In the apache configuration file httpd. conf, find

Options FollowSymLinks
AllowOverride None

Some versions are written in this way.

Options FollowSymLinks ExecCGI Indexes
AllowOverride None

In short, no matter how you write, you just need

Change AllowOverride None to AllowOverride All.

Then find

LoadModule rewrite_module modules/mod_rewrite.so

Remove the "#" in front of this, that is, remove the comments, and then restart apache!

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.