Remove the index.php from the CI frame URL under nginx

Source: Internet
Author: User

The default URL rule for the CI framework is the entry file with the app, for example:

Example.  COM/index.  PHP/News/article/my_article          

In the above URL with the portal file index.php, such a URL rule is not friendly to the search engine, then how to remove the index.php it?
Apache Environment:
Use the. htaccess file to set some simple rules to remove it. The following is an example of using the "negative" method to redirect non-specified content:

Rewriteengine onrewritecond!^ (index\.php|  Images|  Robots\.txt)rewriterule^ (. *)/index.  PHP/[L]              

If your project is not in the root directory, please change the above sentence to read:

Rewriterule^ (. *)$ index.  PHP/[L]       

In the above example, any HTTP requests that can implement any non-index.php, images, and robots.txt are directed to index.php.

Nginx Environment:
Modify the Nginx configuration file and add the following code to the server segment:

Location/{

Index index.php INDEX.HML index.htmIf (-f $request _filename/index.php) { rewrite (. *) $1/index.php ; } if (!- E $request _filename { rewrite (. *)/index.; }} /span>

Remove index.php from the CI framework URL under nginx

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.