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.
And then I uploaded everything from the public directory to the /public_html directory.
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';
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>
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?
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>
Then try without index.php
it should work perfectly.