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 ??