Laravel 5 显示404未发现错误的Laravel 5.8
我将index.php文件路径public更改为root。在根路径中添加.htaccess文件后,laravel 5.7每个页面都可以正常工作。但在Laravel5.8中,当我点击另一个页面时,它显示404NotFound 下面是我的.htaccess文件Laravel 5 显示404未发现错误的Laravel 5.8,laravel-5,laravel-5.8,Laravel 5,Laravel 5.8,我将index.php文件路径public更改为root。在根路径中添加.htaccess文件后,laravel 5.7每个页面都可以正常工作。但在Laravel5.8中,当我点击另一个页面时,它显示404NotFound 下面是我的.htaccess文件 <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine On #Send request via index.php RewriteCond %{REQUE
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
#Send request via index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d``
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Laravel.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>
您的webroot必须设置为/public目录。不要试图搜索将index.php和.htaccess文件从/public移动到Laravel应用程序根目录的其他解决方案。绝对没有理由要将webroot从/public移动到/。index.php位于/public中是有原因的。如果您的web主机不提供将web根目录移动到其他目录的功能,请切换您的主机 可能是您创建了文件夹作为示例,并试图通过示例访问它 即 然而像这样访问它
localhost/example/public
localhost/example/public