Home > PHP Framework > ThinkPHP > body text

How to remove url index in thinkphp

藏色散人
Release: 2022-12-05 10:44:03
Original
1490 people have browsed it

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 都可以 没太大的影响)
Copy after login

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 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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template