vendredi 14 juin 2019

How to rewrite url with try_files css, js file [ laravel + vue-cli nginx]

I'm using vue-cli for frontend and laravel for backend

Here is my nginx config

server{
 // Here I set up laravel in root project
 listen 80;
    root /var/www/html/serverside/public;
    index  index.php index.html index.htm;
    server_name  localhost;

  //Here is vuejs project
  location / {
    root /var/www/html/frontend;
    try_files $uri $uri/ = /index.html;
  }

  //Here is example when I want to use route path in laravel project
  location /admin {
   try_files $uri $uri/ /index.php?$query_string;
  }
 }

The Problem is assets() in laravel redirect to /var/www/html/frontend;

How can I make asset in laravel redirect in /var/www/html/serverside/public;

I try to do something like this

// if enter /admin-js I want to read app.js file but it didnt working
location /admin-js {
        rewrite ^/admin-js/$ /var/www/html/serverside/public/js/app.js;
        try_files $uri $uri/ /index.php?query_string;
    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire