In addition to the index.php in the CodeIgniter address

Source: Internet
Author: User
Tags codeigniter
Remove the index.php from the CodeIgniter address

Version: codeigniter_2.0.1

You want the URL for the CI app to not contain index.php
Example: http://www.example.com/index.php/product/712
Hope to become this http://www.example.com/product/712
So the URL is more beautiful, perhaps this seo more friendly, through Urlrewrite can achieve

Just use the following 3 steps to get it done:
1. Create the. htaccess write rewrite rules as follows
[Code]

??? Rewriteengine on
??? Rewritebase/

??? #Removes access to the system, folder by users.
??? #Additionally this would allow you to create a system.php controller,
??? #previously this would not has been possible.
??? # ' system ' can is 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 are attempting to access a valid file,
??? #such as an image or CSS document, if this isn ' t true it sends the
??? #request to index.php
??? Rewritecond%{request_filename}!-f
??? Rewritecond%{request_filename}!-d
??? Rewriterule ^ (. *) $ index.php?/$1 [L]



??? # If We don ' t have Mod_rewrite installed, all 404 ' s
??? # can is sent to index.php, and everything works as normal.
??? # submitted By:elliothaughin

??? ErrorDocument 404/index.php
?
[/code]

2. Set $config[' Index_page ' to be vacant
Open the file system/application/config/config.php the code
[PHP] $config [' index_page '] = "index.php"; [/php]
Switch
[PHP] $config [' index_page '] = '; [/php]

3. Make sure Apache supports URL rewriting and restarts Apache

  • 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.