Site logo

[Resolved] Where Do I Add the XFF Code in wp-config.php file

Home Forums Support [Resolved] Where Do I Add the XFF Code in wp-config.php file

Home Forums Support Where Do I Add the XFF Code in wp-config.php file

  • This topic has 5 replies, 2 voices, and was last updated 5 years ago by Elvin.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1717258
    Ken

    Searched and the two answers were not helpful at all.

    Original Problem:

    I’m getting “Origin Error” when going to my wp-login, trying to work inside the dashboard, navigating the site, because I’m using Ezoic.

    Ezoic suggested among other things (which I tried) to implement X-Forwarded-For (XFF) Header on WordPress.

    “Simply copy and paste the code below to your “theme’s” wp-config.php file.

    Present Problem: Ezoic says that we need to contact the “Theme Owners” to learn where to add the XFF code.

    My Question: Can someone, preferably with a screenshot, show me exactly where to paste the code?

    It’s no problem getting access to my site, I use Mac app Forklift.

    Here’s the code I need to paste in Generatepress’s wp.config.php file:

    // Use X-Forwarded-For HTTP Header to Get Visitor’s Real IP Address

    if ( isset( $_SERVER[‘HTTP_X_FORWARDED_FOR’] ) ) {

    $http_x_headers = explode( ‘,’, $_SERVER[‘HTTP_X_FORWARDED_FOR’] );

    $_SERVER[‘REMOTE_ADDR’] = $http_x_headers[0];

    }

    #1717291
    Elvin
    Staff
    Customer Support

    Hi there,

    wp-config.php isn’t a theme file, it’s a core WordPress file on the site’s root folder. You will need to access this file using FTP or any file editor that your hosts server panel provides.

    Example: https://share.getcloudapp.com/ApuYNBn7

    If you don’t know how to do this then speak with your Hosting provider

    #1717301
    Ken

    Hi Elvin,
    Just to confirm. I need to contact my hosting, so they can tell me where in my wp-config.php file I should add the code… correct?

    I know how to access my wp-config.php. I don’t know exactly where to paste the code.

    Hmm, interesting that Ezoic is telling us that we need to contact the Theme Developer.

    If this is in fact wrong, then I’ll sent a feedback to Ezoic saying that we should contact the Host, if that is indeed what we should do.

    Please let me know if you meant that hosting can help with the placement of this code in the wp-config.php.

    Thank you.

    #1717309
    Elvin
    Staff
    Customer Support

    Just to confirm. I need to contact my hosting, so they can tell me where in my wp-config.php file I should add the code… correct?

    If you know how to do it through FTP or your hosting’s file manager tool (if they have one), then you don’t have to contact them and just do it yourself.

    If you don’t know how to, then yes, you have to ask them for assistance.

    The code you’ve provided can be placed on the bottom-most part of the file.

    Hmm, interesting that Ezoic is telling us that we need to contact the Theme Developer.

    If this is in fact wrong, then I’ll sent a feedback to Ezoic saying that we should contact the Host, if that is indeed what we should do.

    It’s not theme specific: https://wordpress.org/support/article/editing-wp-config-php/

    #1717356
    Ken

    The code you’ve provided can be placed on the bottom-most part of the file.

    Yes, that’s what I was looking for.
    Thank you Elvin.

    #1717368
    Elvin
    Staff
    Customer Support

    No problem. 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.