thinkphp hide Index.php/home and allow access to other modules implementation methods

Source: Internet
Author: User
This article mainly introduced about thinkphp hidden index.php/home and allow access to other modules of the implementation method, has a certain reference value, now share to everyone, the need for friends can refer to

Want to achieve the effect is very simple, I have two modules, Home, Wechat.

Http://localhost/index.php/home/index/index shortened to: Http://localhost/index/index

Http://localhost/index.php/wechat/index/index shortened to: Http://localhost/wechat/index/index

Hide index.php, this is relatively simple, I opened. htaccess support on the line, the specific configuration to implement Baidu bar, I use the apache2, build a soft connection into

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

Restart Service

Then, you don't have to do anything, index.php is hidden.

<ifmodule mod_rewrite.c>rewriteengine onrewritecond%{request_filename}!-drewritecond%{REQUEST_FILENAME}!- Frewriterule ^ (. *) $ index.php/$1 [qsa,pt,l]</ifmodule>

This is the thinkphp default. htaccess file content, you can see that index.php can be omitted

Then is the home of the hidden, if we directly in the. htaccess file to write home, then, the other modules we can not access, only use the mechanism provided by thinkphp

There is a lot of talk here, but I find that most of them speak frankly, and none of them are complete.

That's what I'm doing.

Adding a configuration to the common/conf/config.php

' Default_module ' = ' home ', ' module_allow_list ' = = Array (' Home ', ' Wechat ')

Where the ' module_allow_list ' value is the name of all the modules that you allow access to, only the modules that are written in this area can be accessed.

Finally, a lot of people say that adding in the index.php

Define (' Bind_module ', ' Home ');

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.