Hey, did you solve this ? :c
Can't access assets on public after setting document root to /public
Hi there!
I've just recently started using Laravel on a new project and I hit a problem.
So, I think I've set up everything well for a new project and began working on it. Everything is fine on my local machine (Windows, running WAMP) and I've set it up on a personal VPS (Ubuntu, running NGINX), which is also working fine. Now, my employer is using Shared Hosting and the access is sadly very limited. I have ftp access and he can access some stuff on a cPanel. I've tried deploying to the server directly from my local project with PhpStorm. It seemed ok, only bump was that it was directing to a file listing, but when accessing serverlink/public it seemed ok. I've asked my employer to change the document root to /public and everything went downhill, as I now can't access my assets (css/images) which are on /public. The generated links are what they're supposed to be eg: serverlink/css/mycss.css but the file returns a 404 which is rather odd.
Here's my htaccess:
<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>
On my views I'm referencing the assets using blade, like so:
<link href="{{ asset('css/button.css') }}" rel="stylesheet" type="text/css" >
^^ This doesn't show correctly in the forum, I'm using asset('css/something.css') with double curly braces!
What I get when trying to access the files directly in the browser is
"Sorry, the page you are looking for could not be found. 1/1 NotFoundHttpException in RouteCollection.php line 145:"
Can anyone help me out? Going nuts over this, especially as it works fine on my vps! Will I need to forsake Laravel 5 because of the hosting restrictions or can I get around them?
Cheers, Tiago C.
Please or to participate in this conversation.