Welcome to Centmin Mod Community
Become a Member

Nginx Exclude certain folder from 404 redirect for pictures

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by Tythus, Aug 5, 2015.

  1. Tythus

    Tythus Member

    61
    9
    8
    Aug 6, 2014
    Ratings:
    +12
    Local Time:
    8:15 PM
    Code:
    location ~* \.(png|jpg|jpeg|gif) {
        try_files $uri $uri/ @noimage;
    }
    location @noimage {
        rewrite ^ /404.gif;
    }
    
    I have been using this to redirect to a 404 image under an image not being found but would anyone know how to exclude a certain tree from this such as website.com/lel/

     
  2. eva2000

    eva2000 Administrator Staff Member

    58,905
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    5:15 AM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    should be able to just define the excluded location specifically
    Code:
    location ~* /exclude {
    
    }
    
     
  3. Tythus

    Tythus Member

    61
    9
    8
    Aug 6, 2014
    Ratings:
    +12
    Local Time:
    8:15 PM
    so

    Code:
    location ~* /lel{
    
    }
    Should work? will that work for subfolders or only this folder?
     
  4. eva2000

    eva2000 Administrator Staff Member

    58,905
    12,490
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +19,122
    Local Time:
    5:15 AM
    Nginx 1.31.x
    MariaDB 10.x/11.4+/12.3+
    it matches all urls with /lel so yes subfolders it should