Remove index. php from the codeigniter address

Source: Internet
Author: User
Tags codeigniter

Introduction: This is a detailed page for removing index. php from the codeigniter address. It introduces PHP, related knowledge, skills, experience, and some PHP source code.

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

Version: codeigniter_2.0.1

The URL of the Ci application does not contain index. php.
Example: http://www.example.com/index.php/product/712
Http://www.example.com/product/712 like this
In this way, the URL is more beautiful, and Seo may be more friendly, which can be implemented through urlrewrite.

You only need to perform the following three steps:
1. Create an. htaccess write rewrite rule as follows:
[Code]
<Ifmodule mod_rewrite.c>
Rewriteengine on
Rewritebase/

# Removes access to the system folder by users.
# Additionally this will allow you to create a system. php controller,
# Previusly this wocould not have been possible.
# 'System' can be replaced if you have renamed your system folder.
Rewritecond % {request_uri} ^ system .*
Rewriterule ^ (. *) $/index. php? /$1 [l]

# When your application folder isn' t in the system folder
# This snippet prevents user access to the application folder
# Submitted by: fabdrol
# Rename 'application' to your Applications folder name.
Rewritecond % {request_uri} ^ application .*
Rewriterule ^ (. *) $/index. php? /$1 [l]

# Checks to see if the user is attempting to access a valid file,
# Such as an image or CSS document, if this Isn't true it sends
# Request to index. php
Rewritecond % {request_filename }! -F
Rewritecond % {request_filename }! -D
Rewriterule ^ (. *) $ index. php? /$1 [l]
</Ifmodule>

<Ifmodule! Mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# Can be sent to index. php, And everything works as normal.
# Submitted by: elliothaughin

Errordocument 404/index. php
</Ifmodule>
[/Code]

2. Set $ config ['index _ page'] To empty
Open the file system/application/config. phpCode
[PHP] $ config ['index _ page'] = "index. php"; [/PHP]
Change
[PHP] $ config ['index _ page'] = ''; [/PHP]

3. Make sure Apache supports URL rewriting and restart Apache.

More articles about "Remove index. php from codeigniter address"

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/329785.html pageno: 12.

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.