Title: Problem with trailing slash?
Last modified: March 10, 2017

---

# Problem with trailing slash?

 *  Resolved [meadows19](https://wordpress.org/support/users/meadows19/)
 * (@meadows19)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/problem-with-trailing-slash/)
 * Hello,
 * I’m having trouble with this excellent plugin, and I hope you can offer me some
   suggestions.
 * I have two sites: [https://staging.example.com/](https://staging.example.com/)
   
   and [https://www.example.com/members/](https://www.example.com/members/)
 * I have a plugin that sends users an email link containing `?crfw_cart_hash=`
   
   I want that link to go through, and have configured it as follows:
 *     ```
         // whitelist URL if query string contains 'parameter'
   
       if ( (isset($_GET['rcpga-invite-key']) || isset($_GET['crfw_cart_hash'])) ) 
         {
           $whitelist[] = site_url($_SERVER['REQUEST_URI']);
         }
   
         return $whitelist;
       }
       ```
   
 * Now the problem is that it works fine on the staging site, but doesn’t work on
   the live site. On the live site, it sends me back to the login page.
 * The link to the staging site looks like:
    `https://staging.example.com/?crfw_cart_hash
   =bE&crfw_email=jimbob%2Bcart123%40gmail.com&crfw_action=checkout`
 * And the link to the live site looks like:
    `https://www.example.com/members?crfw_cart_hash
   =y4&crfw_email=jimbob%2B999%40gmail.com&crfw_action=checkout`
 * I’ve tried putting a trailing slash after the word ‘members’ in this URL, but
   that doesn’t work either.
 * Do you have any idea what could be wrong?
 * Thanks for your help!
    -  This topic was modified 9 years, 3 months ago by [meadows19](https://wordpress.org/support/users/meadows19/).

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

 *  Thread Starter [meadows19](https://wordpress.org/support/users/meadows19/)
 * (@meadows19)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/problem-with-trailing-slash/#post-8898142)
 * see post below
    -  This reply was modified 9 years, 3 months ago by [meadows19](https://wordpress.org/support/users/meadows19/).
 *  Thread Starter [meadows19](https://wordpress.org/support/users/meadows19/)
 * (@meadows19)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/problem-with-trailing-slash/#post-8898220)
 * I tried it on the live site, with the Whitelist plugin disabled (email link works
   as expected) and enabled (link doesn’t work, and redirects to login page).
 * The redirection traceroute is the exact same, except with the Whitelist plugin
   disabled, it stops here:
 * **301 Redirect**
    `https://www.example.com/members/gold/?crfw_cart_hash=y4&crfw_email
   =jimbob%2B999%40gmail.com&crfw_action=checkout&crfw_redirected=1`
 * but with the Whitelist plugin enabled, it adds one final step to the end:
 * 302 Redirect
    `https://www.example.com/members/login/`
 *  Plugin Author [Kevin Vess](https://wordpress.org/support/users/kevinvess/)
 * (@kevinvess)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/problem-with-trailing-slash/#post-8901243)
 * I’m not sure why whitelisting the URL based on the existence of those query string
   parameters is only working on your staging site.
 * I’m fairly certain the trailing slash is not the cause – the `site_url($_SERVER['
   REQUEST_URI']);` line returns whatever the full URL is, regardless of trailing
   slashes.
 * However, since your URL structures are different between your staging and live
   sites – maybe try the `v_forcelogin_bypass` filter instead?
 *     ```
       /**
        * Bypass Force Login to allow for exceptions.
        *
        * @return bool Whether to disable Force Login. Default false.
        */
       function my_forcelogin_bypass( $bypass ) {
         if ( isset($_GET['rcpga-invite-key']) || isset($_GET['crfw_cart_hash']) ) {
           $bypass = true;
         }
         return $bypass;
       }
       add_filter('v_forcelogin_bypass', 'my_forcelogin_bypass', 10, 1);
       ```
   
 *  Thread Starter [meadows19](https://wordpress.org/support/users/meadows19/)
 * (@meadows19)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/problem-with-trailing-slash/#post-8902059)
 * Thank you very much Kevin. Using the `v_forcelogin_bypass` as you suggested does
   seem to solve the problem!
 * My last question is: I now have two separate plugins. The one you wrote above
   using `v_forcelogin_bypass` and another one using `v_forcelogin_whitelist` as
   follows:
 *     ```
       <?php
   
       function my_forcelogin_whitelist( $whitelist ) {
   
         // these pages can be accessed without logging in
   
         $whitelist[] = site_url( '/login/' );
         $whitelist[] = site_url( '/bronze/' );
         $whitelist[] = site_url( '/silver/' );
         $whitelist[] = site_url( '/gold/' );
   
         return $whitelist;
       }
   
       add_filter('v_forcelogin_whitelist', 'my_forcelogin_whitelist', 10, 1);
       ```
   
 * Can I combine them both into a single plugin, and if so, do I just paste them
   into one file?
 * Thanks again Kevin.
 *  Plugin Author [Kevin Vess](https://wordpress.org/support/users/kevinvess/)
 * (@kevinvess)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/problem-with-trailing-slash/#post-8903692)
 * Great, I’m glad that worked!
 * > Can I combine them both into a single plugin, and if so, do I just paste them
   > into one file?
 * Yes, you may paste both filter codes into one plugin file, or you may add them
   to your theme’s functions.php file and not use a plugin at all. Totally up to
   you how you want to add these filters to your WordPress install.
 * Be sure to rate and review my plugin to let others know how you like it.
 * Thanks for using Force Login!

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

The topic ‘Problem with trailing slash?’ is closed to new replies.

 * ![](https://ps.w.org/wp-force-login/assets/icon.svg?rev=1904031)
 * [Force Login](https://wordpress.org/plugins/wp-force-login/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-force-login/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-force-login/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-force-login/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-force-login/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-force-login/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Kevin Vess](https://wordpress.org/support/users/kevinvess/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/problem-with-trailing-slash/#post-8903692)
 * Status: resolved