Sunday, February 20, 2022

[FIXED] Laravel 5 & Vue components – Remove Public from URL

Issue

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?


Solution

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



Answered By - JJMontalban

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.