To remove the index.php from the CodeIgniter (CI) default URL (full version)

Source: Internet
Author: User
Tags codeigniter

To remove the index.php from the CodeIgniter (CI) Default URL:

1. Open the Apache configuration file, conf/httpd.conf:

1 LoadModule rewrite_module modules/mod_rewrite.so

Remove the # before the line.

Search AllowOverride None (there are multiple places in the configuration file), read the comment information, and change the relevant. Htaccess's line information to:

1 AllowOverride All

2. Under the CI root directory, that is, in the index.php,system of the same sibling directory, the establishment of the. htaccess, directly establish the file name is not successful, you can first create a Notepad file, save as the name of the file. The content is as follows (also described in the CI manual):

12345 RewriteEngine onRewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L]

If the file is not in the root directory of WWW, for example mine is:

1 http://localhost/ci_demo_1/index.php/

The third line needs to be rewritten as

1 RewriteRule ^(.*)$ /CI/index.php/$1 [L]

In addition, my index.php's sibling directory also has the assets folder, these need to filter remove, the second line needs to be rewritten as:

1 RewriteCond $1 !^(index\.php|images|<span style="text-decoration: underline;">assets</span>|robots\.txt

3. In the CI in the configuration file (application/config/config.php)

1 $config[‘index_page‘] = "index.php";

Change into

1 $config[‘index_page‘] = "";

Restart Apache, complete.

=============================================================================================================== ==========

PHP Framework ci to index.php method


There are many ways to introduce the. htaccess file, if it is in the test environment, dynamic and static files put into a piece, may test there is a certain problem (because all directed to index.php), static Web page access.

Here's a way to just modify the http.conf file,

Steps:

1: Add in the Configuration virtual directory

1234567891011 <Directory />     Options Indexes FollowSymLinks     AllowOverride all     Order allow,deny     Allow fromall   </Directory>   <IfModule mod_rewrite.c>    RewriteEngine on    RewriteRule ^/script/(.*) /script/$1 [L]    RewriteRule ^(.*)$ /index.php?/$1 [L]   </IfModule>

2 Put the following line in front of it;

1 LoadModule rewrite_module modules/mod_rewrite.so

3 Restart Apache, no need to join. htaccess file

To remove the index.php from the CodeIgniter (CI) default URL (full version)

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.