Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How thinkphp5 hides home

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you "thinkphp5 how to hide home", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "thinkphp5 how to hide home" this article.

Thinkphp5 hide home method: 1, add configuration "'DEFAULT_MODULE' = >' Home'," in config.php; 2, add "define ('BIND_MODULE','Home');" in index.php.

This article operating environment: Windows7 system, thinkphp v5.1, Dell G3 computer.

Thinkphp hides index.php/home and allows access to the implementation of other modules:

The effect I want to achieve is simple. I have two modules, Home and Wechat.

Http://localhost/index.php/home/index/index shortened to: http://localhost/index/indexhttp://localhost/index.php/wechat/index/index shortened to: http://localhost/wechat/index/index

Hide index.php, this is relatively simple, I turn on .htaccess support on it, specific configuration to execute Baidu, I use apache2, set up a soft connection

Ln-s / etc/apache2/mods-available/rewrite.load / etc/apache2/mods-enabled/rewrite.load

Restart the service

Then, without doing anything, index.php is hidden.

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

This is the default .htaccess file content of ThinkPHP. As you can see, index.php can be omitted.

Then there is the hiding of home. If we write home directly in the .htaccess file, then we will not be able to access other modules, so we will have to use the mechanism provided by thinkphp.

There are a lot of things to say here, but I find that most of them are straight to the point, and no one says it is complete.

Here's what I'm doing.

Add configuration to Common/Conf/config.php

'DEFAULT_MODULE' = >' Home','MODULE_ALLOW_LIST' = > array ('Home','Wechat')

Where the value of 'MODULE_ALLOW_LIST'' is the name of all the modules you are allowed to access, and only the modules written here can be accessed.

Finally, a lot of people talk about adding index.php.

Define ('BIND_MODULE','Home')

The above is all the content of the article "how thinkphp5 hides home". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report