i have a Laravel project, and i have deployed it on Hostinger as a shared host,
my shared host structure :
[public_html]
->
[contains all the files of laravel project also public of laravel]
[public_html]
->
[contains .htaccess beside laravel project]
[.htaccess beside laravel project contains this]
->
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
the problem is
now everything working correctly but the problem is i have /public
after my domain
it should be www.domain.com/
but i get www.domain.com/public/
but also i can go to www.domain.com/login
also i can go to www.domain.com/public/login
but i can not go to www.domain.com/
it redirects me back to www.domain.com/public/
how to solve it ? please
2
Answers
Good day; for your website to work without /public
An example is given below change (project_dir) to the directory you create the same level as public _html
require DIR.’/../(project_dir)/vendor/autoload.php’; // probably line 34
$app = require_once DIR.’/../(project_dir)/bootstrap/app.php’; //probably line 47
You might also need to set the permission for the public folder to 775 but this is not neccesary
The safest and simplest method is to use symlinks.
First, create a new directory outside public_html. I follow the practice of
/home/username/domainname
Next delete your
public_html
directoryNow create a symlinks from
/home/username/domainname/public
to/home/username/public_html
The command would be
And that’s it, your full application code will be in the
domainname
directory while only the contents of the public directory will be inpublic_html
The main benefits of this approach is
domainname
directory and changes will automatically reflect