Home Backend Development PHP Tutorial Analysis of how to remove index.php_PHP tutorial in CodeIgniter URL

Analysis of how to remove index.php_PHP tutorial in CodeIgniter URL

Jul 21, 2016 pm 03:02 PM
codeigniter index.php rewrite url remove how yes of kind parse default

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):

Copy code The code is as follows:

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'] = ""; .
Copy code The code is as follows:

/*
|--------- -------------------------------------------------- ---------------
| 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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327910.htmlTechArticleThe default rewrite url of CI is similar to this. For example, your CI root directory is under /CodeIgniter/, Your secondary URL below is similar to http://localhost/CodeIgniter/index.php/welcome. No...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of Oracle error 3114: How to solve it quickly Detailed explanation of Oracle error 3114: How to solve it quickly Mar 08, 2024 pm 02:42 PM

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

Why NameResolutionError(self.host, self, e) from e and how to solve it Why NameResolutionError(self.host, self, e) from e and how to solve it Mar 01, 2024 pm 01:20 PM

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

Introduction to how to remove WPS watermark Introduction to how to remove WPS watermark Mar 28, 2024 am 11:31 AM

Introduction to how to remove WPS watermark

Analysis of new features of Win11: How to skip logging in to Microsoft account Analysis of new features of Win11: How to skip logging in to Microsoft account Mar 27, 2024 pm 05:24 PM

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

What is the difference between html and url What is the difference between html and url Mar 06, 2024 pm 03:06 PM

What is the difference between html and url

Analysis of the meaning and usage of midpoint in PHP Analysis of the meaning and usage of midpoint in PHP Mar 27, 2024 pm 08:57 PM

Analysis of the meaning and usage of midpoint in PHP

Apache2 cannot correctly parse PHP files Apache2 cannot correctly parse PHP files Mar 08, 2024 am 11:09 AM

Apache2 cannot correctly parse PHP files

Parsing Wormhole NTT: an open framework for any Token Parsing Wormhole NTT: an open framework for any Token Mar 05, 2024 pm 12:46 PM

Parsing Wormhole NTT: an open framework for any Token

See all articles