Site logo

Archived topic

Could you please help me where to add the X-Forwarded-For code in the wp-config.

3 replies · Started by rajkumarsm on April 21, 2020

Viewing posts 1–4 of 4

Hi there.

I would like to implement XFF for my site.

Could you please help me where to add the X-Forwarded-For code in the 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];

}

Thanks in advance
STM

Hi there,

the wp-config.php file can be found in the Root folder of your Website. You will need to access this file using FTP or any file editor that your hosts server panel provides.

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

Where in the file should we add it

I would assume you can add it at the end of the file.

You might need to check with whoever provided the code for this as it's not theme related.

This archived topic is closed to new replies.