Title: Custom Plugin fail to redirect
Last modified: December 3, 2020

---

# Custom Plugin fail to redirect

 *  Resolved [invictumhr](https://wordpress.org/support/users/invictumhr/)
 * (@invictumhr)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/custom-plugin-fail-to-redirect/)
 * Hello,
 * We have custom plugin which redirects VPN ips to some custom url. Example if 
   our domain is example.com and some user open [https://www.example.com](https://www.example.com)
   he should remain on this url. But if user with ip xxx.xxx.xxx.xxx types [https://www.example.com](https://www.example.com)
   then user should be redirected to [https://www.example.com/?vpn=1](https://www.example.com/?vpn=1).
 * We have plugin which manages redirects and it is working fine. But if we activete
   LSCWP then redirects do not works.
 * Can we in our custom plugin write code that will execute even if page is cached
   with LSCWP ?
 * Our custom plugin has add_action(‘wp’, ‘our_function_name’), and function our_function_name
   reads user IP, then checks is this IP in mysql database table with defined IPS,
   and if it is in this table then we redirect to {current_url} + “?|&” + “vpn=1”
 * Thank you and best regards,
    Ivan
    -  This topic was modified 5 years, 6 months ago by [invictumhr](https://wordpress.org/support/users/invictumhr/).

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

 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/custom-plugin-fail-to-redirect/#post-13743064)
 * Hi,
 * Is it possible you can insert a cookie from your function ?
 * once there is a cookie , we can use it for vary
 * like if you can set a cookie like
 * use_vpn = y
 * use_vpn = n
 * then when request come with different cookie value , same page will get different
   result.
 * Best regards,
 *  Thread Starter [invictumhr](https://wordpress.org/support/users/invictumhr/)
 * (@invictumhr)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/custom-plugin-fail-to-redirect/#post-13743834)
 * Hello,
 * Yes, i can set cookie. Ok, i will try to set a cookie. And i will contact you
   back with results 🙂
 * Do i need to setup this new cookie in LSWPC plugin?
 * Or is there hook that is fired even if page is cached, so i can with my plugin
   integrate this hook?
 * Thank you
    -  This reply was modified 5 years, 6 months ago by [invictumhr](https://wordpress.org/support/users/invictumhr/).
 *  Thread Starter [invictumhr](https://wordpress.org/support/users/invictumhr/)
 * (@invictumhr)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/custom-plugin-fail-to-redirect/#post-13743906)
 * Hello,
 * If i set cookie vpn=no, only first user after purging have this cookie. When 
   i load page with another browser then in new browser there is no this cookie.
 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/custom-plugin-fail-to-redirect/#post-13747588)
 * Hi,
 * yeah … that was half way
 * if you can set cookie , then add this into top of your .htaccess
 * RewriteRule .* – [E=Cache-Vary:vpn]
 * purge all and try again.
 * Best regards,
 *  Thread Starter [invictumhr](https://wordpress.org/support/users/invictumhr/)
 * (@invictumhr)
 * [5 years, 6 months ago](https://wordpress.org/support/topic/custom-plugin-fail-to-redirect/#post-13763290)
 * Hello [@qtwrk](https://wordpress.org/support/users/qtwrk/) ,
 * It is working now. Thank you very much for your help 😉
 * Best regards,
    Ivan

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

The topic ‘Custom Plugin fail to redirect’ is closed to new replies.

 * ![](https://ps.w.org/litespeed-cache/assets/icon-256x256.png?rev=2554181)
 * [LiteSpeed Cache](https://wordpress.org/plugins/litespeed-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/litespeed-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/litespeed-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/litespeed-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/litespeed-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/litespeed-cache/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [invictumhr](https://wordpress.org/support/users/invictumhr/)
 * Last activity: [5 years, 6 months ago](https://wordpress.org/support/topic/custom-plugin-fail-to-redirect/#post-13763290)
 * Status: resolved