每个路由在共享主机上显示404消息 [英] Each route is showing 404 message on shared hosting
问题描述
我正在尝试在 A2Hosting 共享主机上部署 laravel
应用程序.我的文档根目录是:/public_html 目录.我将 laravel
应用程序中的所有内容(除了公用文件夹之外)都上传到了托管的/beta目录.
I am trying to deploy a laravel
application on A2Hosting shared hosting. My document root is: /public_html directory. I uploaded everything from my laravel
application except the public folder to the /beta directory of hosting.
然后,我将所有内容从公共目录上传到/public_html 目录.
And then I uploaded everything from the public directory to the /public_html directory.
在我的index.php文件中,我更改了以下两行:
In my index.php file, I changed the following two lines:
require __DIR__.'/../beta/vendor/autoload.php';
$app = require_once __DIR__.'/../beta/bootstrap/app.php';
现在,我只能正确看到应用程序的主页.也就是mydomain.com.在mydomain.com之后的任何超链接都显示 404消息.在我的视图文件中,这就是我所指的路径:
Now I am only seeing the home page of my application correctly. That is, mydomain.com. Any hyperlink followed by mydomain.com is showing a 404 message. In my view files, this is how I am referring to a path:
<a href="/login">Login</a>
但是在部署应用程序之后,每当我单击该链接(即mydomain.com/login)时,都会得到 404 Not Found:在此服务器上找不到请求的资源!
消息.我尝试在< a>
标记中将/login
更改为 login
.结果相同.我该如何解决?
But after deploying the application, whenever I hit that link, i.e. mydomain.com/login, I get the 404 Not Found: The resource requested could not be found on this server!
message. I tried changing /login
to login
in the <a>
tag. Same result. How do I solve this?
推荐答案
艾森海姆,这是htaccess的问题:在您的Web项目的根文件夹中获得一个 .htaccess
文件.
Eisenheim, this is htaccess issue: get one .htaccess
file in root folder of your web-project.
并将以下代码放入其中,
And put the following code inside it,
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
然后尝试在没有 index.php
的情况下,它应该可以完美运行.
Then try without index.php
it should work perfectly.
这篇关于每个路由在共享主机上显示404消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!