在 .htaccess 文件內容如下條件時 / 不是在如下條件自測
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
第一種
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項目了呢!
---------------------
作者:誰偷了我的小魚乾兒
來源:CSDN
原文:https://blog.csdn.net/Albert_1000/article/details/54862705
版權聲明:本文爲博主原創文章,轉載請附上博文鏈接!
第二種
配置的訪問項目配置
<Directory /var/www/>
AllowOverride all(中這一項改爲all)
</Directory>
第三種
結合第一種和第二種內容都改動試一下就OK了 。
是不是很簡單哦!!!!