2," to the project's configuration file; 3. Open Apache's httpd.conf file; 4. Delete the # symbol in front of mod_rewrite.so; 5. Restart Apache."/> 2," to the project's configuration file; 3. Open Apache's httpd.conf file; 4. Delete the # symbol in front of mod_rewrite.so; 5. Restart Apache.">

Home  >  Article  >  PHP Framework  >  How to remove url index in thinkphp

How to remove url index in thinkphp

藏色散人
藏色散人Original
2022-12-05 10:44:031451browse

Thinkphp method to remove url index: 1. Move the .htaccess file to the root directory of the project; 2. Add "'URL_MODEL'=> 2," to the project configuration file; 3. Open Apache's httpd.conf file; 4. Delete the # symbol in front of mod_rewrite.so; 5. Restart Apache.

How to remove url index in thinkphp

The operating environment of this tutorial: Windows 7 system, ThinkPHP version 5, Dell G3 computer.

How to remove url index in thinkphp?

Removing index.php from ThinkPHP URL

Removing index.php from ThinkPHP URL is divided into two steps:

One: First What you want to achieve is to remove index.php in the browser navigation bar and still access the website normally

1, move the .htaccess file to the root directory of your project

2, Add

'URL_MODEL'             =>  2,       
// URL访问模式,可选参数0、1、2、3,代表以下四种模式:
  // 0 (普通模式); 1 (PATHINFO 模式); 2 (REWRITE  模式); 3 (兼容模式)  默认为PATHINFO 模式(经测验,此处 'URL_MODEL' => 1或2 都可以 没太大的影响)

3 to the project configuration file, and perform relevant configuration in Apache

In Apache's httpd.conf file, remove the # in front of LoadModule rewrite_module modules/mod_rewrite.so and restart Apache

2: After completing the above operation, you can access the website normally without adding index.php. However, most links in websites using ThinkPHP are implemented using U(). You will find that The link to jump to when you click on the font or picture with the 3499910bf9dac5ae3c52d5ede7383485 tag exists in index.php, so the second step below is to remove the index.php

brought by using U() in the entry file. Just add define('__APP__',' ') to index.php in the root directory of the project.

Okay, give it a try!

Recommended learning: "thinkPHP Video Tutorial"

The above is the detailed content of How to remove url index in thinkphp. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn