当我在域名末尾添加index.php
(www.example.com/index.php
)然后点击其他路由时,index.php
会添加到他们的网址。但我在其他Laravel网站上看到,即使你添加index.php
然后点击其他路线,网址也将是:
www.example.com/ROUTE_NAME
(我的意思是index.php
已经消失。)
我如何为我的网站实现这一目标?
我正在使用共享主机(Apache + Nginx)和我的.htaccess文件:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>