Thinkphp how to remove index. php_PHP in the url tutorial

Source: Internet
Author: User
How does thinkphp remove index. php from the url. The URLs of applications developed using thinkphp usually contain an index. php. if we need pseudo-static or SEO optimization, this is very difficult and meaningless. The URLs of applications developed using thinkphp usually contain index. php. if we need pseudo-static or SEO optimization, this is very difficult to understand and meaningless. So how can we remove index. php from the thinkphp app url?

We can solve this problem through URL rewriting. of course, this problem requires the server to enable the URL_REWRITE module. Therefore, before proceeding to the following steps, determine whether your server has been enabled or whether URL_REWRITE can be enabled.

(1) If URL_REWRITE is not enabled, you need to find the httpd. conf configuration file in Apache and find the following line:

# LoadModule rewrite_module modules/mod_rewrite.so

Remove the preceding alert code and continue to find the following sentence:

AllowOverride None

Change All the preceding statements to AllowOverride All.

After the preceding modification, restart the Apache server.

(2) create a. htaccess file under the root directory of the application. Add the following code to the file:

 
  RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
 

In fact, the above has implemented the removal of index. php characters in the url to directly access the application. However, the constant/index of thinkphp will also occur in the above two steps. the index will still be automatically included in php/Article. the php string completely solves this problem by adding the following configuration in the project configuration file:

'URL_MODEL'=>'2'

At this point, index. php in the thinkphp app url is completely invisible.

Note: In windows, you cannot directly create a. htaccess file. you can first create a file (for example, www.phpernote.com.txt), and then enter the following command in DOS:

Rename www.phpernote.com.txt. htaccess

Articles you may be interested in
  • How to remove the index. php string from the website url developed by codeIgniter
  • Reasons why PHP adds a backslash before the quotation mark and how PHP removes the backslash, there are three ways to disable the php magic quotation mark
  • Summary of system constants in the Action Controller of thinkphp
  • Thinkphp prints the last SQL statement
  • Difference between execute and query methods in ThinkPHP
  • Php bom removal tool, php batch removal of bom code
  • The last record of the volist loop in the thinkphp Template
  • Thinkphp like query

The URLs of applications developed by thinkphp usually contain an index. php. if we need pseudo-static or SEO optimization, this is not easy to understand or make sense. So...

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.