Kevin
Kevin

Reputation: 2688

nGinx Rewrite Issue exclusion

I am attempting to rewrite my /support url, so I can grab the "page" as an appended querystring.

The issue I am running into now, is my assets are also contained in the /support subfolder, so they too are getting re-written.

How can I change this to exclude my assets? (where assets = /support/assets/styles, /support/assets/scripts, etc...)

Here is my current location block

location /support/ {
    index index.php;
    rewrite ^/support/(.*) /support/index.php?_p=$1 last;
    try_files $uri $uri/ /support/index.php?$args;
}

Upvotes: 1

Views: 73

Answers (1)

Richard Smith
Richard Smith

Reputation: 49692

You can check for the assets with try_files before performing the rewrite by using a named location.

For example:

location /support/ {
    index index.php;
    try_files $uri $uri/ @rewrite;
}
location @rewrite {
    rewrite ^/support/(.*) /support/index.php?_p=$1 last;
}

See this document for more.

Upvotes: 1

Related Questions