


Analysis of how to remove index.php_PHP tutorial in CodeIgniter URL
Jul 21, 2016 pm 03:02 PM
The default rewrite URL of CI is similar to this. For example, your CI root directory is under /CodeIgniter/, and your secondary URL below is similar to http://localhost/CodeIgniter/index.php/welcome. It doesn’t look good. How can I remove the index.php in it?
1. Open the apache configuration file, conf/httpd.conf:
LoadModule rewrite_module modules/mod_rewrite.so, and remove the # before the line.
Search for AllowOverride None (there are many places in the configuration file), look at the comment information, and change the line information in the relevant .htaccess to AllowOverride All.
2. In the root directory of CI, that is, in the directory at the same level as index.php and system, create .htaccess. Directly creating the file name will not succeed. You can create Notepad first. file, just save it as a file with this name. The content is as follows (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 at the root of www directory, for example mine is: http://www.nowamagic.net/CodeIgniter/, the third line needs to be rewritten as RewriteRule ^(.*)$ /CodeIgniter/index.php/$1 [L].
In addition, there are js folders and css folders in the same directory of my index.php. These need to be filtered and removed. The second line needs to be rewritten as: RewriteCond $1 !^(index.php|images|js| css|robots.txt)
3. Change $config['index_page'] = "index.php"; in the CI configuration file (system/application/config/config.php) config['index_page'] = ""; .
/*
|--------- -------------------------------------------------- ---------------
| Index File
|------------------------- --------------------------------------------------
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
*/
$config['index_page'] = '';
Restart apache

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Detailed explanation of Oracle error 3114: How to solve it quickly

Why NameResolutionError(self.host, self, e) from e and how to solve it

Introduction to how to remove WPS watermark

Analysis of new features of Win11: How to skip logging in to Microsoft account

What is the difference between html and url

Analysis of the meaning and usage of midpoint in PHP

Apache2 cannot correctly parse PHP files

Parsing Wormhole NTT: an open framework for any Token
