Deploy to shared hosting, not loading assets.

When deploying to shared hosting, there are assets of course, but for some reason unknown to me, they are not loading. Almost not at all in Firefox, only partially in Chrome (which is also a mystery to me). You can try to look at it: https://dev.forvix.work/admin or /wms
Solution:
Just found an article and it solved it for me. Article: https://medium.com/@dedanirungu/how-to-host-a-laravel-project-on-a-shared-hosting-via-cpanel-5bd54f9a8f1a Only to have .htaccess in root with this content: ...
Medium
How to Host a Laravel Project on a Shared Hosting via CPanel
Add a .htaccess file to the root and there will be no need of copying or editing files from the public folder.
Jump to solution
12 Replies
Lara Zeus
Lara Zeus8mo ago
do these files exist in the public folder? try access any file/image in the public folder make sure your .htaccess file is correct
Michal Čabala
Michal Čabala8mo ago
Files are in the public folder. Seems like there are some problems with .htaccess, probably in the root. When i removed it, public is in URL and assets are loading. But cannot login (nothing happens). .htaccess in root:
Options +SymLinksIfOwnerMatch
RewriteEngine On

# Allow Installatron requests
RewriteCond %{REQUEST_FILENAME} deleteme\.\w+\.php
RewriteRule (.*) - [L]

RewriteRule ^ index.php [L]
Options +SymLinksIfOwnerMatch
RewriteEngine On

# Allow Installatron requests
RewriteCond %{REQUEST_FILENAME} deleteme\.\w+\.php
RewriteRule (.*) - [L]

RewriteRule ^ index.php [L]
.htaccess in public folder:
<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]

# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
<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]

# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Lara Zeus
Lara Zeus8mo ago
try disable the one in the root?
Michal Čabala
Michal Čabala8mo ago
404
Solution
Michal Čabala
Michal Čabala8mo ago
Just found an article and it solved it for me. Article: https://medium.com/@dedanirungu/how-to-host-a-laravel-project-on-a-shared-hosting-via-cpanel-5bd54f9a8f1a Only to have .htaccess in root with this content:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Loading PHP as if is public/ from /
RewriteRule ^$ public/index.php [L]
#Loading page as if is public/ from /
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]

RewriteRule (^\.|/\.) - [F]

<Files .env>
order allow,deny
Deny from all
</Files>


</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Loading PHP as if is public/ from /
RewriteRule ^$ public/index.php [L]
#Loading page as if is public/ from /
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]

RewriteRule (^\.|/\.) - [F]

<Files .env>
order allow,deny
Deny from all
</Files>


</IfModule>
Medium
How to Host a Laravel Project on a Shared Hosting via CPanel
Add a .htaccess file to the root and there will be no need of copying or editing files from the public folder.
Michal Čabala
Michal Čabala8mo ago
The more "funny thing" will be updates 😄
Fogzy
Fogzy8mo ago
@Michal Čabala Michale, is there any way to change the root directory of the vhost to /public, so you can get rid of the root htaccess?
Michal Čabala
Michal Čabala8mo ago
I think I don't understand your question well (probably of a language?) ...can you be more detailed?
Lara Zeus
Lara Zeus8mo ago
I don't think it's possible in shared hosting to edit apache configuration
Michal Čabala
Michal Čabala8mo ago
I'm lucky enough that my hosting have SSH etc., but I can't work with it yet, as I'm totally noob about it and still learning. And right now i have this hosting just for testing (and learning) purposes. Just a question...in what is the difference between shared hosting and VPS for running Laravel and Filament app? If you have SSH, Git etc. on shared hosting?
Lara Zeus
Lara Zeus8mo ago
will not all shared hosting offers SSH and more stuff, as you said you're lucky enough 🙂 not sure if this is default or not, but as i've seen most of the shared hosting has limitations
Michal Čabala
Michal Čabala8mo ago
So I'm lucky enough...some time ago I was looking for hosting that can handle phpBB or Xenforo well and some guy gave me advice for this hosting. Right now I'm running phpBB there and recently added domain for testing my personal project in Laravel and Filament. It's like shared hosting, but probably looks like VPS as of the features- just take a look at it: https://exon.io/nexthosting (switch to english, the cheaper plan (about 15 EUR/month).
exon.io - nextHosting | Výkonný hosting s cPanelem
Jeden hosting pro všechno. Od PHP a Node.js až po Python nebo Ruby