【问题标题】:Laravel 5.8 Remove index.php from urlLaravel 5.8 从网址中删除 index.php
【发布时间】:2019-09-14 12:00:28
【问题描述】:

我确实从 GitHub、StackOverflow 等不同的资源中尝试了很多解决方案,但在 laravel 5.8 版本中没有得到从 url 中删除 index.php 的解决方案。此问题仅在 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?/$1 [QSA,L]

</IfModule> 

如果有人有解决方案。请告诉我

【问题讨论】:

标签: php .htaccess laravel-5.8


【解决方案1】:

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

为了使用 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>

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-27
      • 2017-01-28
      • 2018-03-04
      • 1970-01-01
      相关资源
      最近更新 更多