项目在localhost上工作正常,但是当我在服务器上传它时它会显示
Not FoundThe requested URL /yes was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request
只有/ route正在工作其他路由不能在route.php文件上工作
答案 0 :(得分:5)
您需要在服务器上设置.htaccess
重写。您可能需要安装并启用mod_rewrite
apache模块(或所选http服务器的类似替代方案)。
检查应用的公用文件夹是否有.htaccess
文件,类似于:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
答案 1 :(得分:0)
.dotfiles是隐藏的,可以在控制面板上启用显示隐藏文件。
<\ n>在Laravel 5.6中编辑从公共复制的.htacess
文件并粘贴此代码
<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>
也可以在public / .htacess或public_html / .htacess
中执行相同操作答案 2 :(得分:0)
pp具有一个.htaccess文件,类似于:
选项-MultiViews
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
答案 3 :(得分:0)
在您的文件夹中将 RewriteBase 添加到project_folder / .htaccess和project_folder / public / .htaccess
选项-MultiViews-索引
RewriteEngine On
RewriteBase /your_project_folder/public
# 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]
答案 4 :(得分:0)
我有同样的问题。我将.htaccess文件复制到了本地主机的公用文件夹中,并将其粘贴到服务器上的.htaccess文件中,并且可以正常工作。
答案 5 :(得分:0)
只是一个观察。当public_html文件夹中没有.htaccess且php版本已更改或升级时,.htaccess文件中会生成该文件。因此,请正确检查它是否在laravel .htaccess之前存在。看来mime_module指定了项目的版本