thinkphp怎么隱藏index.php

thinkphp隱藏index.php的方法:首先去掉URL地址里面的入口文件index.php;然后配置web服務(wù)器的重寫規(guī)則即可。以apache為例,我們需要在入口文件的同級添加htaccess文件。

thinkphp怎么隱藏index.php

可以去掉URL地址里面的入口文件index.php,但是需要額外配置WEB服務(wù)器的重寫規(guī)則。

(推薦教程:java視頻教程

以Apache為例,需要在入口文件的同級添加.htaccess文件(官方默認(rèn)自帶了該文件),內(nèi)容如下:

thinkphp怎么隱藏index.php

立即學(xué)習(xí)PHP免費學(xué)習(xí)筆記(深入)”;

如果用的phpstudy,規(guī)則如下:

thinkphp怎么隱藏index.php

如果index.php文件存放在public中,規(guī)則如下:

thinkphp怎么隱藏index.php

接下來就可以使用下面的URL地址訪問了

thinkphp怎么隱藏index.php

如果你使用的apache版本使用上面的方式無法正常隱藏index.php,可以嘗試使用下面的方式配置.htaccess文件:

thinkphp怎么隱藏index.php

如果是nginx環(huán)境的話,可以在Nginx.conf中添加:

location?/?{?//?…..省略部分代碼????if?(!-e?$request_filename)?{ ????????rewrite??^(.*)$??/index.php?s=/$1??last;????????break; ????} }vhosts-conf server?{ ????????listen???????80; ????????server_name??xhb.com?www.xhb.com; ????????root???"F:/project/xhb"; ????????location?/?{ ????????????index??index.html?index.htm?index.php; ????????????if?(!-e?$request_filename)?{ ????????rewrite??^(.*)$??/index.php?s=/$1??last; ????????break; ????} ????????????#autoindex??on; ????????} ????????location?~?.php(.*)$?{ ????????????fastcgi_pass???127.0.0.1:9000; ????????????fastcgi_index??index.php; ????????????fastcgi_split_path_info??^((?U).+.php)(/?.+)$; ????????????fastcgi_param??SCRIPT_FILENAME??$document_root$fastcgi_script_name; ????????????fastcgi_param??PATH_INFO??$fastcgi_path_info; ????????????fastcgi_param??PATH_TRANSLATED??$document_root$fastcgi_path_info; ????????????include????????fastcgi_params; ????????} }

thinkphp怎么隱藏index.php

相關(guān)推薦:java視頻教程

以上就是

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點贊13 分享