我确实尝试过很多来自不同资源的解决方案,比如GitHub,StackOverflow等,但是没有得到解决方案来从laravel 5.8版本的url中删除index.php。仅在5.8版中会出现此问题
这是我的.htaccess文件代码。哪个位于根目录:
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>
如果有人有解决方案。请告诉我
您必须在Apache服务器上启用mod_rewrite
。重写模块需要应用这些设置。你也启用了.htaccess
。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [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>