How to remove index. php from codeigniter URL

Source: Internet
Author: User
Tags codeigniter

The default rewrite URL of Ci is similar to this. For example, if your CI root directory is under/codeigniter/, your second-level URL is similar to 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 (there are multiple configuration files), view the comments, and change the row information of related. htaccess to 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 ):CopyCodeThe Code is as follows: 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/, and the third line is rewriterule ^ (. *) $/codeigniter/index. php/$1 [l]
In addition, my index. PHP Directory has the JS folder and CSS folder under the same level, which need to be filtered out, and the second line needs to be rewritten as: rewritecond $1! ^ (Index \. php | images | JS | CSS | robots \. txt)

3. set the configuration file (System/application/config. $ config ['index _ page'] = "index. PHP "; set $ config ['index _ page'] = "";.
Copy codeThe Code is as follows :/*
| --------------------------------------------------------------------------
| Index file
| --------------------------------------------------------------------------

| Typically this will be your index. php file, unless you 've renamed it
| 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

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.