R
R
romanyich2020-12-16 17:31:38
Nginx
romanyich, 2020-12-16 17:31:38

NGINX application in a subdirectory, how to give assets correctly?

In the '/blog' subdirectory of the application I want to show another application (wordpress)

location /blog {
  rewrite ^/blog/(.*)$ /$1 break;

  proxy_pass http://example.com;
  proxy_redirect off;
}


However, the asset paths are broken. If you manually add /blog/ to the path, they are displayed. I think you need to do something with the try_files directive, like this:

try_files $uri @new;

location @new {
  # something
}


I believe that I am close to solving the problem... Please help me with the correct directive

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2020-12-16
@ky0

It's not very clear, I'll try to figure it out.
If you need one to open in /blog, and another in all other places, then this is done by two locations - /blogand /. No rewrites are needed, just add your wordpress in the first one, and the standard behavior / directories / whatever you have in the second one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question