Codeigniter URL rewriting (removing the index. php route)

Source: Internet
Author: User
Tags codeigniter

Introduction: This is a detailed page of codeigniter URL rewriting (removing index. php Routing). It introduces PHP, related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 340520 'rolling = 'no'>

In the codeigniter path configuration, the index. php route is used by default. It is best to remove this index. php when beautifying the URL for Seo, that is, rewrite the URL.

The correct method is provided here:

① Enable the rewrite module of the httpd. conf configuration file of Apache, that is, the rewrite_module module, and configure AllowOverride to all.

② If Apache is configured, configure the. htaccess file now. If your file is configured in the root directory as follows:

<Ifmodule mod_rewrite.c>

Rewriteengine on

Rewritecond % {request_filename }! -D

Rewritecond % {request_filename }! -F

Rewriterule ^ (. *) $/index. php/$1 [QSA, PT, l]

</Ifmodule>

Note that if your file is not in the root directory, for example, in the CI folder of the root directory, You need to configure the file as follows:

<Ifmodule mod_rewrite.c>
 
Rewriteengine on
 
Rewritecond % {request_filename }! -D
 
Rewritecond % {request_filename }! -F
 
Rewriterule ^ (. *) $/Ci/index. php/$1 [QSA, PT, l]
 
</Ifmodule>

In this way, Your URL rewriting will take effect.

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/340520.html pageno: 7.

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.