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

Source: Internet
Author: User

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

The result is very simple. I have two modules: Home and Wechat.

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

Hide index. php. This is relatively simple. Just enable the. htaccess support. Execute Baidu for specific configuration. I use apache2 to create a soft connection.
 
ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
 

Restart service

Then, you don't need to do anything. index. php will be hidden.

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

This is the default. htaccess File Content of ThinkPHP. You can see that index. php can be omitted.

 

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

 

There are a lot of arguments here, but I found that most of them are just a part of them, and none of them are complete.

 

My approach is like this.

Add configuration in Common/Conf/config. php

'DEFAULT_MODULE' => 'Home','MODULE_ALLOW_LIST' => array('Home','Wechat')
Among them, the value of 'module _ ALLOW_LIST 'is the name of all the modules you are allowed to access. Only the modules written here can be accessed. Finally, many people say that index. php should be added

define('BIND_MODULE','Home');
We do not recommend this. With this configuration, only the Home module of your project can be accessed. What if there are multiple modules ??? Is it used? M = & c = & a = this ugly form ??

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.