Thinkphp hides Index.php/home and allows access to other modules

Source: Internet
Author: User

 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/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.

<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

Array (' Home ', ' Wechat ')

Where ' module_allow_list ' is the value of all of the module names you allow access to, only the modules that are written in it. Finally, a lot of people say that adding in the index.php
Define (' Bind_module ', ' Home ');

Do not recommend this, such a configuration, your project is only the home module can be accessed, if there are multiple modules??? Does it use the ugly form of m=&c=&a=??

Thinkphp hides Index.php/home and allows access to other modules

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.