Report this

What is the reason for this report?

Is it safe to use this code with WordPress to get cloudflare SSL working

Posted on October 15, 2021

I want to ask if this code snippet is safe to use in WordPress. As I am new and their are many experts here. So I would like to ask them about this code.

if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' === $_SERVER['HTTP_X_FORWARDED_PROTO'] ) { $_SERVER['HTTPS'] = 'on'; }

This code solves the redirect loop when using cloudflare SSL certificate.

Many forums and threads I have suggested to use similar code but some say that $_SERVER['HTTPS'] = 'on'; using this code is not a good practice. I want someone to guide



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Yes, its found ok. If any issue kindly ping me.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.