Nginx [SOLVED]: nGinx Rewrite Issue exclusion

Nginx [SOLVED]: nGinx Rewrite Issue exclusion

Home Forums Nginx Nginx [SOLVED]: nGinx Rewrite Issue exclusion

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #36721

    Anonymous

    QuestionQuestion

    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;
    }
    

    #36722

    Anonymous

    Accepted AnswerAnswer

    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.

    Source: https://stackoverflow.com/questions/47982195/nginx-rewrite-issue-exclusion
    Author: Richard Smith
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.