• A lot of people are having problems redirecting an image to a post. I found a temporary solution (especially in my case). But I need a little help to perfect it.

    I just remove jpg/png/jpeg from this config file :

    # set long EXPIRES header on static assets
            location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
                    expires 30d;
                    access_log off;
            }
    }

    And clear cache+restart system to make it work. After that, image redirection work perfectly.

    But here comes a new problem, the server request will increase significantly because there is no cache. This is a bad thing.

    I’m curious. Is there some kind of script/regext to exclude the redirection plugin from the nginx caching?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author John Godley

    (@johnny5)

    I don’t know what kind of script you are thinking about, but there is no magic solution.

    If you are using Nginx the easiest way is usually to export the redirect to Nginx from the import/export page. Then it will operate before any other configuration.

    Thread Starter Balkis Anton Nurohman

    (@balkisanton)

    Um, ok. Got it.

    I’m just wondering if there is another way.

    By the way, i have 56 image redirects. Does it also cause bad things when I add it to nginx redirection directly?

    Plugin Author John Godley

    (@johnny5)

    What kind of bad thing? Most decisions are usually a compromise, so it really depends what you are worried about happening. I don’t think 40 redirects will cause much difference to anything though.

    Thread Starter Balkis Anton Nurohman

    (@balkisanton)

    Hmm, ok i think i got the point. Thanks for answering my questions

    Really great plugin you’ve been made. And also great work. Keep it up!

    Thread Starter Balkis Anton Nurohman

    (@balkisanton)

    For anyone is looking for a solution to this problem, the only way is to do a redirect in the system directly

    First, you must create a redirection as usual (all you need), but don’t forget to add a different tag (Nginx, Apache or WordPress) so you can easily export it

    Go to Redirection plugin > Import/Export > on the Export menu, change “Everything” to your tag (Nginx, Apache or WordPress). Change and match “Complete data (JSON) to yours > click View > copy these rewrite rules

    Then, in this case I’m using nginx, so I have to paste rewrite rules in the configuration file (https version) before caching takes effect. My configuration is on /etc/nginx/conf.d/httpsver… (every configuration is different)

    Add paste it before caching system applied

    The caching conf should be something like this (just an example, it can be different depending on your server configuration) :

    location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
                    expires 30d;
                   ....
    
    }

    All you need to do is paste before the caching conf

    If you using apache and litespeed, it’s more easy. Simply export redirection rewrite rules to htaccess

    Don’t forget, you have to clear the old cache too using the command :
    rm -rf /var/cache/nginx/*

    Check the redirection

    If not running, try reloading nginx :
    sudo nginx -s reload

    Thank me later

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Exclude Redirection Plugin From Nginx Caching’ is closed to new replies.