If you have just been in touch with CI or have just studied the CI user manual, how to effectively Delete the index in the URL. php makes the URL look more friendly and beautiful. It may be the first complicated problem you are facing! This post is not original, but a combination of various opinions! However, the solution proposed in this post can effectively solve the configuration in Apache and IIS environments.
If you have just been in touch with CI or have just studied the CI user manual, how to effectively Delete the index in the URL. php makes the URL look more friendly and beautiful. It may be the first complicated problem you are facing! This post is not original, but a combination of various opinions! However, the solution proposed in this post can effectively solve the configuration in Apache and IIS environments.
If you have just been in touch with CI or have just studied the CI user manual, how to effectively Delete the index in the URL. php makes the URL look more friendly and beautiful. It may be the first complicated problem you are facing! This post is not original, but a combination of various opinions! However, the solution proposed in this post can effectively solve the configuration problems in both Apache and IIS environments. It can also be effective, avoid the no input file specified error on some virtual LINUX virtual hosts! If you are still struggling to find a solution to the index. php problem, it may be your last stop!
Official Solution
By default, the index. php file will be included in your URL:
Example.com/index.php/news/article/my_article
You can easily use the. htaccess file to set some simple rules to delete it. The following example uses the "negative" method to redirect unspecified content:
HTML
RewriteEngine on
RewriteCond $1! ^ (Index \. php | images | robots \. txt)
RewriteRule ^ (. *) $/index. php/$1 [L]
NOTE: If your project is not in the root directory, change the above sentence to RewriteRule ^ (. *) $ index. php/$1 [L].
In the preceding example, any HTTP requests other than index. php, images, and robots.txt can be directed to index. php.
My ultimate solution, but in practice, the above solution is only applicable to servers running in the Apache environment and not fully applicable! When the CI program is located in a non-root directory or on some virtual hosts, the preceding solution may cause errors such as "404 error" or "no input file specified. baidu has found a universal method to effectively Delete the index in the URL path after referring to the Liberation solution for related issues. php method. The Code is as follows:
When the index is in the root directory, you can create a. htaccess file in the root directory where index. php is located and use the following code:
HTML
RewriteEngine on
RewriteCond $1! ^ (Index \. php | robots \. txt)
RewriteRule ^ (. *) $/index. php? /$1 [L]
When index. php is not in the root directory, you can create a. htaccess file in the directory where index. php is located and use the following code:
HTML
RewriteEngine on
RewriteCond $1! ^ (Index \. php | images | robots \. txt)
RewriteRule ^ (. *) $/path_to_app/index. php? /$1 [L]
Note: replace path_to_app with the directory of the file where your index. php is located. Assume that your index. php is placed under the tool sub-folder in the root directory. You can write it like this:
HTML
RewriteEngine on
RewriteCond $1! ^ (Index \. php | images | robots \. txt)
RewriteRule ^ (. *) $/tool/index. php? /$1 [L]
The above solution should solve how to effectively Delete the index in the URL in the Apache environment. php problems. If you have other questions, please comment or leave a message and leave a valid contact information. I will try to solve the problem for you and notify you of the possible solution in time!
In addition, for how to effectively Delete index. php In the URL in the IIS environment, refer to this article:
IIS7.5 remove index. php web. config configuration file reference: how to delete the ultimate solution of index-php in the url