preparing laravel app for hosting on a shared hosting platform

Viewed 55

I am trying to deploy an incomplete laravel app to a shared hosting (to give a client a feel of the project). However, the directory structure of the shared hosting is quite different from what I developed locally - the presence of the public_html folder. My css and js are located in the public folder.I have also linked my css file as such : <link rel="stylesheet" href="/css/style.css"> which works perfectly locally. But when deploying to the shared hosting <link rel="stylesheet" href="/css/style.css"> will not work as it does not point to the public folder. I intend to place the index.php file and .htaccess in the root folder (public_html) and change require __DIR__.'/../vendor/autoload.php'; to require __DIR__.'/vendor/autoload.php'; also change $app = require_once __DIR__.'/../bootstrap/app.php'; to $app = require_once __DIR__.'/bootstrap/app.php';.

my question is how do I make asset('public/css/style.css') work locally so as to not make much changes when deploying to a shared hosting, as asset('public/css/style.css') does not work on my local environment?

Note: <link rel="stylesheet" href="/css/style.css"> will not work on the shared hosting because I want to keep the css files in the public folder and not in the root directory (public_html).

1 Answers

try this when you link CSS, js files

*If your index.php file is inside the public folder

"{{URL('/css/style.css')}}"

  • If your index.php file is inside the root folder

"{{URL('public/css/style.css')}}"

Related