在ThinkPHP5.0中,出於優化的URL訪問原則,還支持通過URL重寫隱藏入口文件,下面以Apache為例說明隱藏應用入口文件index.php的設置。
下面是Apache的配置過程,可以參考下:
1、httpd.conf配置文件中加載了mod_rewrite.so模塊, 開啟虛擬主機,這一條必須開啟
2、AllowOverride None 將None改為 All,不是httpd.conf 是配置httd-vhosts.conf, 原因是因為apache 只識別index.php ,index.html,
配置如下圖
3、在應用入口文件同級目錄添加.htaccess文件,內容如下:
<IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule>