Laravel 5.8 从 url 中删除 index.php

Laravel 5.8 Remove index.php from url

我确实尝试了很多来自不同资源的解决方案,例如 GitHub、Whosebug 等,但没有找到从 url 中删除 index.php 的解决方案 laravel 5.8 版本。此问题仅出现在版本 5.8

这是我的 .htacess 文件代码。放在根目录下:

DirectoryIndex index.php
<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On
    RewriteBase /laravel/portal/

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?/ [QSA,L]

</IfModule> 

如果有人有解决办法。请告诉我

您必须在 Apache 服务器上启用 mod_rewrite。需要重写模块来应用这些设置。您还启用了 .htaccess.

<IfModule mod_rewrite.c>
  RewriteEngine On 
   RewriteRule ^(.*)$ public/ [L]
</IfModule>

我找到了解决方案。感谢您的帮助。

为了使用mod_rewrite,您可以在终端中输入以下命令:

sudo a2enmod rewrite

之后重新启动 apache2
sudo systemctl restart apache2

这里是根目录.htaccess文件:

<IfModule mod_rewrite.c>
  Options +FollowSymLinks -Indexes
RewriteEngine On

RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>