Laravel helpers do not work in shared hosting production mode

Asked

Viewed 337 times

-1

I have an Laravel 5.6 application hosted at Ycorn, there, because it is shared, I do not have SSH access, which makes it difficult to implement the framework.

With that, the helpers {{asset()}} and {{url()}} can’t find my CSS, JS, etc. This is causing me a lot of headache as the application doesn’t work 100%.

But, example the url() works for routes as well as route(), but to access files I have to do something like

href="url('public/images/'.$imagem)"

I’ve read that it might be .htacess, but I couldn’t.

In the hosting the site is in the folder public_html, so I moved my files from the folder /public/ from Laravel to the /public_html and adjusted to work.

Here is mine .htaccess:

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

I’ve tried to put the RewriteBase /public /public_html but nothing worked

1 answer

-1

Try to follow the guidelines of this link: https://medium.com/@luisdalmolin/how-to-deploy-of-a-apply%C3%A7%C3%A3o-Roomable-in-a-shared-bc1142cbb9

Especially the part below, so you don’t need to move your public to public_html:

8- Create a symbolic link to the public folder

Here is the real reason you need an SSH access to hosting. We need to tell the server that when the user accesses the folder public_html (or www, or anything else), it actually you will access ~/apps/seusite.com/public. For this, we will create a link symbolic.

$ cd ~ && ln -s ~/apps/seusite.com/public public_html Theoretically, by now your site should be working properly (A not If you are at Locaweb, then you will probably have to see the next step)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.