[Vuejs]-Laravel 5 & Vue components โ€“ Remove Public from URL

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

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.

Leave a comment