1. 程式人生 > >TP5如何隱藏入口檔案index.php

TP5如何隱藏入口檔案index.php

一、Apache 在ThinkPHP5.0中,出於優化的URL訪問原則,還支援通過URL重寫隱藏入口檔案,下面以Apache為例說明隱藏應用入口檔案index.php的設定。 下面是Apache的配置過程,可以參考下: 1、httpd.conf配置檔案中載入了mod_rewrite.so模組 2、AllowOverride None 將None改為 All 3、在應用入口檔案同級目錄新增.htaccess檔案,內容如下: Options +FollowSymlinks -Multiviews RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]//---------------此處與官網不同; 4、重啟Apche; 二、Nginx 開啟nginx配置檔案 [

[email protected] ~]#cd /etc/nginx/conf.d/ [[email protected] conf.d]# vi default.conf 複製程式碼 location / { // …..省略部分程式碼 if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } } --------------------- 本文來自 awake720 的CSDN 部落格 ,全文地址請點選:https://blog.csdn.net/awake720/article/details/81103816?utm_source=copy