PHPCodeIgniter (CI) Remove index. php

Source: Internet
Author: User
Remove index. php from the default url of CodeIgniter (CI). Step 1: Open the apache configuration file, confhttpd. conf: LoadModulerewrite_modulemodulesmod_rewrite.so, and remove the # Before this line. Search for AllowOverrideNone (there are multiple configuration files), view the comments, and send the related. htaccess line

To remove index. php from the default url of CodeIgniter (CI), follow these steps: 1. Open the apache configuration file: conf/httpd. conf: LoadModule rewrite_module modules/mod_rewrite.so. Search for AllowOverride None (there are multiple configuration files), view the comments, and send the related. htaccess line

To remove index. php from the default CodeIgniter (CI) url:

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

LoadModule rewrite_module modules/mod_rewrite.so

Remove the # Before the row.

Search for AllowOverride None (there are multiple configuration files), view the comments, and change the related. htaccess row information:

AllowOverride All

2. under the root directory of CI, that is, in index. php, system directory at the same level, create. htaccess, directly creating the file name will not succeed, you can first create a notepad file, save it as a file with this name. The content is as follows (this is also introduced in the CI manual ):

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

If the file is not in the root directory of www, for example, my file is:

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

The third line needs to be rewritten

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

In addition, the assets folder under the same directory of my index. php needs to be filtered out, and the second line needs to be rewritten:

RewriteCond $1 !^(index\.php|images|assets|robots\.txt

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

$config['index_page'] = "index.php";

Change

$config['index_page'] = ""; 

Restart apache.

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

Php framework ci de-index. php Method


There are many methods to introduce online. if the htaccess file is a dynamic or static file in the test environment, some problems may occur during the test (because all files are directed to the index. php), static Web pages cannot be accessed.

Here, we provide a method to modify the http. conf file,

Steps:

1: add

 
       Options Indexes FollowSymLinks      AllowOverride all      Order allow,deny       Allow from all         
 
       RewriteEngine on      RewriteRule ^/script/(.*) /script/$1 [L]     RewriteRule ^(.*)$ /index.php?/$1 [L]    
 

2. Remove the following line.

LoadModule rewrite_module modules/mod_rewrite.so

3. Restart apache without adding the. htaccess file.

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.