0

I'm using the URL like web.com/sys/test, which is rewritten in nginx config to web.com?system=sys&id=test via rewrite ^/(\w+)/(\w+)$ /?system=$1&id=$2 break;.

Also, all my resource files have relative path.

Therefore I get error: Unable to find web.com/sys/css/user.css, however user.css is located in /css/.

Is there a way to solve the problem remaining the relative path for resource files?

Leeloo
  • 350
  • 6
  • 20
  • One simple way is to use URLs relative to the domain root, with a leading slash: `/css/user.css` – CBroe Aug 07 '17 at 12:01
  • It would be absolute then – Leeloo Aug 07 '17 at 12:05
  • Well unless you want to do even more rewriting to “fix” the paths to resources embedded using relative URLs, this is the easiest way to achieve this. Of course you can also use `../` to go up one folder level ... but that is not going to be fun if your rewriting should ever start to emulate more folder levels in the document URL as well. – CBroe Aug 07 '17 at 12:08
  • I haven't understood anything ;) Could you answer in answer form? – Leeloo Aug 07 '17 at 12:18
  • I don’t see what sense writing an answer would make, as long as you don’t understand anything. If you have trouble understanding something, then tell us what specifically that is first of all. – CBroe Aug 07 '17 at 12:21
  • I just want you to answer in answer form, so we could discuss below your answer, not here ;) – Leeloo Aug 07 '17 at 12:26
  • @CBroe `` This solved – Leeloo Aug 07 '17 at 12:45

1 Answers1

0

Used base tag:

<base href="/">

However, in some cases this method may just add a whole lot of new problems. Look at this link

Leeloo
  • 350
  • 6
  • 20
  • 1
    Welcome to Stack Overflow! Thank you for this code snippet, which may provide some immediate help. A proper explanation [would greatly improve](//meta.stackexchange.com/q/114762) its educational value by showing *why* this is a good solution to the problem, and would make it more useful to future readers with similar questions. Please [edit] your answer to add explanation, and give an indication of what limitations and assumptions apply. In particular, `BASE` is supposed to contain an *absolute* URL, so you should indicate that this is a an unreliable non-standard solution. – Toby Speight Aug 07 '17 at 14:10