aravel 配置 隐藏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;
}
附
laravel框架实现去掉URL中index.php的方法
1、将框架根目录下的server.php文件重命名为index.php
2、将框架根目录下的文件夹public下的.htaccess文件复制到框架根目录下,与index.php处于同一目录
3、修改Apache的httpd.conf文件
1、httpd.conf文件所在路径\bin\apache\apache2.4.23\conf\httpd.conf,例如,我的电脑中httpd.conf路径为:D:\wamp\bin\apache\apache2.4.23\conf\httpd.conf
找到httpd.conf文件之后,我们就来修改他吧!
2、在154行左右,找到#LoadModule rewrite_module modules/mod_rewrite.so代码,去掉代码前面的#号
3、重启Apache服务
现在是不是不用在URL中输入讨厌的index.php也能访问web项目了呢!