[PHP] Remove index. php from CodeIgniterURL

Source: Internet
Author: User
Tags codeigniter
The default rewriteurl in www. nowamagic. netphpphp_RemoveIndexInCi.phpCI is similar. For example, if your CI root directory is under CodeIgniter, your second-level url is similar to localhostCodeIgniterindex. phpwelcome. Not very nice. How can I remove index. php from it?

The default rewrite url for http://www.nowamagic.net/php/php_RemoveIndexInCi.php CI is similar to this, for example, if your CI root directory is under/CodeIgniter/, your second-level url is like this http: // localhost/CodeIgniter/index. php/welcome. Not very nice. How can I remove index. php from it?

Http://www.nowamagic.net/php/php_RemoveIndexInCi.php


The default rewrite url of CI is similar to this,

For example, if your CI root directory is under/CodeIgniter,

The second-level url below is similar.

Http: // localhost/CodeIgniter/index. php/welcome.


Not very nice. How can I remove index. php from it?

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 (multiple configuration files exist ),

View the comments and change the row information of related. htaccess to AllowOverride All.


2. Under the root directory of CI, that is, under the same directory of index. php and system,

Create. htaccess. 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://www.nowamagic.net/CodeIgniter,


The third line needs to be rewritten

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


In addition, my index. php directory contains the js folder and css folder,

These need to be filtered out, and the second line needs to be rewritten as: RewriteCond $1


! ^ (Index \. php | images | js | css | robots \. txt)



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


$ Config ['index _ page'] = "index. php ";

Change

$ 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'] = '';

OK. Remember to restart apache.

Related Article

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.