How to remove the index. php string from the website url developed by codeIgniter

Source: Internet
Author: User

If you use codeIgniter (CI) as a website friend, you will find that any url of the website will contain an index by default. php, from the SEO perspective, has little impact on the website, but it is very uncomfortable for the beauty of the url, next let's take a look at how to remove the index in the url of a website developed using codeIgniter. php.

Before performing the following operations, make sure that the environment on your website supports url rewriting using. htaccess. If you can, continue with the following operations:

Create a. htaccess file in the root directory of the website and enter the following content:

RewriteEngine onRewriteBase /RewriteCond %{REQUEST_FILENAME} !-fRewriteCond $1 !^(index\\.php|images|css|js|robots\\.txt)RewriteRule ^(.*)$ /index.php/$1 [L]

The fourth line of the above Code is to exclude some directories or files so that these directories will not be rewritten to index. php, which is generally used in external resources such as images, js, and css. That is to say, all non-PHP code should be excluded. (Here I excluded the css directory js directory and the robots.txt file from the images directory. Of course, index. php should also be excluded)

Find the application/config. php file, and set:

$config['index_page'] = "index.php";

Change

$config['index_page'] = "";
Articles you may be interested in
  • How to remove ads on the dedeCMS background login page
  • How does thinkphp remove index. php from the url?
  • How to optimize website pages and increase webpage loading speed
  • Summary of the JavaScript method for removing string Spaces
  • Thinkphp intercepts Chinese strings
  • Shoulder, back muscle group exercise-Bring Up-bend up rowing-Move up-Stand Up-Stand up weight bend up-Sit posture neck pull down-bend upright hold up-neck front wide hold up
  • Php bom removal tool, php batch removal of bom code
  • Note the following when querying strings with single quotes and inserting strings with single quotes in Mysql:

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.