laravel隱藏index.php的方法:1、開啟Apache mod_rewrite模塊,并修改htaccess文件;2、在Nginx配置文件中通過“try_files $uri $uri/...”指令實現隱藏index.php。

laravel 配置 隱藏index.php
Apache
首先保證你的Apache mod_rewrite 模塊已經開啟. 框架默認有一個 public/.htaccess 文件可以實現隱藏 index.php 的訪問.
如果無效的話,可以試試下面的規則:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]Nginx
在Nginx配置文件中通過下面的指令實現隱藏 index.php:
location / {
try_files $uri $uri/ /index.php?$query_string;
}





