Sapnesh Naik Sapnesh Naik - 5 months ago 31
Apache Configuration Question

Laravel | Shared hosting routes not working properly

I am trying to deploy my Laravel project on a shared host(godaddy) and so far I have only partially succeeded.

Steps I followed:


  • Create a subdomain
    abc.xyz.com
    , root ->
    public_html/finance/.

  • Upload my laravel project to a folder which is at same level as that of
    public_html

  • softlink
    the
    public
    directory of my project to
    public_html/finance/

  • I found that going to
    abc.xyz.com
    didn't work but
    abc.xyz.com/public
    did so I set up a redirect which redirects
    abc.xyz.com
    to
    abc.xyz.com

  • making
    Storage
    accessible for web.

  • dumpautoload
    , caching
    config
    and
    routes
    .

  • migarting
    databases
    .



Now I can successfully login which takes me to
abc.xyz.com/public
but my all other routes which does not have
/public
do not work.
For example:


  • abc.xyz.com/public - works

  • abc.xyz.com/home - doesn't work



I noticed that if I manually add
/public
to all routes they work!. so
abc.xyz.com/public/home
works.

my .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>


So how can append
/public
like
abc.xyz.com/public
to all the routes?

I am not very good at modifying
.htaccess
but I tried some solutions from online and they did not work.

Answer Source