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:
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 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 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
from
all
</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)