Title: Exclude Redirection Plugin From Nginx Caching
Last modified: October 11, 2022

---

# Exclude Redirection Plugin From Nginx Caching

 *  Resolved [Balkis Anton Nurohman](https://wordpress.org/support/users/balkisanton/)
 * (@balkisanton)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/exclude-redirection-plugin-from-nginx-caching/)
 * 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?
    -  This topic was modified 3 years, 8 months ago by [Balkis Anton Nurohman](https://wordpress.org/support/users/balkisanton/).
    -  This topic was modified 3 years, 8 months ago by [Balkis Anton Nurohman](https://wordpress.org/support/users/balkisanton/).

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [John Godley](https://wordpress.org/support/users/johnny5/)
 * (@johnny5)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/exclude-redirection-plugin-from-nginx-caching/#post-16088408)
 * 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](https://wordpress.org/support/users/balkisanton/)
 * (@balkisanton)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/exclude-redirection-plugin-from-nginx-caching/#post-16088770)
 * 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?
    -  This reply was modified 3 years, 8 months ago by [Balkis Anton Nurohman](https://wordpress.org/support/users/balkisanton/).
    -  This reply was modified 3 years, 8 months ago by [Balkis Anton Nurohman](https://wordpress.org/support/users/balkisanton/).
 *  Plugin Author [John Godley](https://wordpress.org/support/users/johnny5/)
 * (@johnny5)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/exclude-redirection-plugin-from-nginx-caching/#post-16088860)
 * 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](https://wordpress.org/support/users/balkisanton/)
 * (@balkisanton)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/exclude-redirection-plugin-from-nginx-caching/#post-16093596)
 * 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](https://wordpress.org/support/users/balkisanton/)
 * (@balkisanton)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/exclude-redirection-plugin-from-nginx-caching/#post-16145320)
 * 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
    -  This reply was modified 3 years, 7 months ago by [Balkis Anton Nurohman](https://wordpress.org/support/users/balkisanton/).
    -  This reply was modified 3 years, 7 months ago by [Balkis Anton Nurohman](https://wordpress.org/support/users/balkisanton/).

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Exclude Redirection Plugin From Nginx Caching’ is closed to new replies.

 * ![](https://ps.w.org/redirection/assets/icon-256x256.jpg?rev=983639)
 * [Redirection](https://wordpress.org/plugins/redirection/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/redirection/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/redirection/)
 * [Active Topics](https://wordpress.org/support/plugin/redirection/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/redirection/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/redirection/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Balkis Anton Nurohman](https://wordpress.org/support/users/balkisanton/)
 * Last activity: [3 years, 7 months ago](https://wordpress.org/support/topic/exclude-redirection-plugin-from-nginx-caching/#post-16145320)
 * Status: resolved