欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

tp5.0框架隱藏index.php入口文件及模塊和控制器的方法分析

 更新時(shí)間:2020年02月11日 13:30:09   作者:Karagrade  
這篇文章主要介紹了tp5.0框架隱藏index.php入口文件及模塊和控制器的方法,結(jié)合實(shí)例形式分析thinkPHP5.0隱藏index.php入口文件及模塊和控制器的具體配置方法、操作技巧與相關(guān)注意事項(xiàng),需要的朋友可以參考下

本文實(shí)例講述了tp5.0框架隱藏index.php入口文件及模塊和控制器的方法。分享給大家供大家參考,具體如下:

1. 隱藏入口文件:

[ IIS ]

在IIS的高版本下面可以配置web.Config,在中間添加rewrite節(jié)點(diǎn):

<rewrite>
 <rules>
 <rule name="OrgPage" stopProcessing="true">
 <match url="^(.*)$" />
 <conditions logicalGrouping="MatchAll">
 <add input="{HTTP_HOST}" pattern="^(.*)$" />
 <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
 <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
 </conditions>
 <action type="Rewrite" url="index.php/{R:1}" />
 </rule>
 </rules>
 </rewrite>

[ Apache ]

httpd.conf配置文件中加載了mod_rewrite.so模塊

AllowOverride None 將None改為 All

把下面的內(nèi)容保存為.htaccess文件放到應(yīng)用入口文件的同級目錄下

<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]//此處與官網(wǎng)不同,官網(wǎng)是這樣寫,嘗試不中,修改成一下可以
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>

2. 模塊和控制器隱藏:

public目錄下的index.php入口文件里添加define('BIND_MODULE', 'index/index');,如下:

<?php
// [ 應(yīng)用入口文件 ]
define('BIND_MODULE', 'index/index');
// 定義應(yīng)用目錄
define('APP_PATH', __DIR__ . '/../application/');
// 加載框架引導(dǎo)文件
require __DIR__ . '/../thinkphp/start.php';

設(shè)置后,我們的URL訪問地址則變成:

http://serverName/index.php/操作/[參數(shù)名/參數(shù)值...]

擴(kuò)展:

tp5.1隱藏控制器和模塊與5.0不同,入口文件中修改如下:

Container::get('app')->bind('index/index')->run()->send()

更多關(guān)于thinkPHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《ThinkPHP入門教程》、《thinkPHP模板操作技巧總結(jié)》、《ThinkPHP常用方法總結(jié)》、《codeigniter入門教程》、《CI(CodeIgniter)框架進(jìn)階教程》、《Zend FrameWork框架入門教程》及《PHP模板技術(shù)總結(jié)》。

希望本文所述對大家基于ThinkPHP框架的PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論