CI removes INDEX. PHP from the URL

Source: Internet
Author: User
CI removes the INDEX from the URL. the default rewriteurl of PHPCI is similar to this in localhost: 9090ciindex. phpnews; the URL written in this way is not very nice and unfriendly. how to remove this INDEX. what about PHP? 1. First, determine whether the server uses AP or IIS. here we will introduce the AP processing method. check whether the AP supports mod_rewrite. if the CI removes INDEX. PHP from the URL

The default rewrite url of CI is similar to this: http: // localhost: 9090/ci/index. php/news;

The URL written in this way is not very nice and unfriendly. how can I remove this INDEX. PHP?

1. First, determine whether the server uses AP or IIS. here we will introduce the AP processing method;

Check whether the AP supports mod_rewrite. if not, open the HTTPD. CONF configuration file.

Find the following sentence:

LoadModule rewrite_module modules/mod_rewrite.so, remove the # before the row;

Search allowoverride none and change it to ALL

2. at the same level of the CI main directory, create a text document, enter the following content, and save it as. htaccess

?

RewriteEngine on ??

RewriteCond $1! ^ (Index \. php | images | robots \. txt )??

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

?

The above code is used to exclude some directories or files, which will not be rewritten to index. php and are generally used for static resources;

That is to say, all non-PHP code should be excluded;

Note:/ci/index. php/$1 depends on your Directory. for example, if your running directory is PL, change CI to PL.

?

3. modify the CI configuration file CONFIG. PHP.

Change $ config ['index _ page'] = "index. php" to $ config ["index_page"] = "";

Restart the AP to check the effect.

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.