0

I'm using a shared hosting with php 7.4 and Laravel. I created the project inside root www/ folder then I need to add a htaccess file to load index.php

source file: www/.htaccess

<IfModule mod_rewrite.c>
  RewriteEngine On

  RewriteRule ^ /public/index.php [L]
</IfModule>

It allowed me to load the website but I couldn't load public content since then. Runing local server I can load the public resources such as stylesheet

<link rel="stylesheet" href="{{ URL::asset('css/main.css')}}">

But on production environment it returns 404 on generated source

<link rel="stylesheet" href="http://neovita.web277.uni5.net/css/main.css">
Roberto Fonseca
  • 115
  • 2
  • 11

2 Answers2

0

Obviously, the correct URL to the CSS file is http://neovita.web277.uni5.net/public/css/main.css.

If the shared hosting in question allows you to put files & folders at the same level with the www folder, you can make the www folder to be the "public" folder of your Laravel project (by renaming public to www). Details here: How to change public folder to public_html in laravel 5

Zoli Szabó
  • 4,366
  • 1
  • 13
  • 19
0

in .htaccess add this

RewriteEngine On
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]