0

I have a Laravel 5 project with Vue components. The project works fine.

But I removed the "/public" from the path using this instruction: Remove /public from URL

And now vue components don't work. Which files do I need to modify to recover Vue components?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
JJMontalban
  • 100
  • 6

2 Answers2

0

I answer myself.

I hope this doesnt affect my status. Please administrators let me know...

After modify I need changing .htaccess like this:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]

In this way the static files components will not be ignored. Like this components work again

JJMontalban
  • 100
  • 6
0

Let me share my experience. Inside public folder, there is .htaccess file. You can copy it into project directory. And in vendor/laravel/src/Illuminate/Foundation/Helpers.php, change asset file like this.

 function asset($path, $secure = null)
 {
     return app('url')->asset("public/".$path, $secure);
 }

It is some bad of touching src file, but it is working well always. Hope it would help you.

BaiMaoli
  • 168
  • 2
  • 15
  • May be works. I didnt try. I have always believed taht you shouldnt touch any that is in /vendor. Everithing found in /vendor directory must be handled only by composer. – JJMontalban Mar 06 '20 at 08:55