thinkphp hide Index.php/home and allow access to other modules _php instances of the implementation method

Source: Internet
Author: User

The effect I want to achieve is 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 open. htaccess support on the line, the specific configuration of the implementation of Baidu Bar, I use the apache2, to establish a soft connection into

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

Restart Service

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

<ifmodule mod_rewrite.c>
rewriteengine on
rewritecond%{request_filename}!-d
Rewritecond%{ Request_filename}!-f
rewriterule ^ (. *) $ index.php/$1 [qsa,pt,l]
</IfModule>

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

Then there is the hidden home, and if we write home directly in the. htaccess file, then the other modules will be inaccessible to us, only using the mechanism provided by thinkphp

There's a lot of talk here, but I've found that most of them are telling the whole story.

That's my way of doing it.

Add Configuration to Common/conf/config.php

' Default_module ' => ' home ',
' module_allow_list ' => Array (' Home ', ' WeChat ')

The value of ' Module_allow_list ' is the name of all the modules you allow to access, and only the modules written here can be accessed.

Finally, a lot of people say to join in the index.php

Define (' Bind_module ', ' home ');

The above is a small series to introduce the thinkphp hidden index.php/home and allow access to other modules to achieve the method, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.