Redirecting staging site to live

Answer these questions to help the Community help you with Security questions.

What is the domain name?

Have you searched for an answer?
yes

Hello, I have the website http://www.bcgel.co.uk working fine, but when comes to the staging.bcgel.co.uk its redirect to the live website. I contacted my server and they told is a problem with Cloudflare which is redirecting. I looked in Cloudflare but can’t find nothing.

They sent this to me to contact cloudflare.

Anyone can help me, please

Thanks

https://staging.bcgel.co.uk/ doesn’t redirect…

curl -I https://staging.bcgel.co.uk
HTTP/2 200
date: Wed, 10 Apr 2024 11:51:56 GMT
content-type: text/html; charset=UTF-8
x-powered-by: PHP/8.1.27
last-modified: Wed, 10 Apr 2024 11:30:40 GMT
cache-control: max-age=0
expires: Wed, 10 Apr 2024 11:51:56 GMT
x-static-config: yes
x-guest-hostname: vps-b8b949
vary: Accept-Encoding
x-via: LHR3
cf-cache-status: DYNAMIC
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=dy2BmLWDLsBnXqXYze%2FqaLby0soqK7XntlGPGsl3SrovDvW%2FOt5Mtaj9O2oWgv%2FelQN1sbQCRs2IzwR%2BWVwRVx79%2Ffczr5GYZ2K0TkdrzJ2ac1QXpRhcXB7LyfQuD7siG07HWACx%2F5QnUMTZJ7Gsn2d2"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 87228722bf1edc4d-LHR
alt-svc: h3=":443"; ma=86400

The link in your screenshot is to http://staging.bcgel.co.uk/wp-admin. Cloudflare redirects it to http://staging.bcgel.co.uk/wp-admin/ (probably due to normalisation), then that is redirected further by Wordpress on your origin server…

curl -I https://staging.bcgel.co.uk/wp-admin
HTTP/2 301
date: Wed, 10 Apr 2024 11:51:08 GMT
content-type: text/html; charset=iso-8859-1
location: http://staging.bcgel.co.uk/wp-admin/
cache-control: max-age=0
expires: Wed, 10 Apr 2024 11:51:08 GMT
x-via: LHR1
cf-cache-status: DYNAMIC
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=f%2FtiKTiuWnD9FPVNfirc9hxfA89jJgOEX598e8fgM3dvZTppdRk7%2BNenb%2BD1HAppN2vVlciek47t9p9s6H8PO0gFk5SXCcan84uCym3sMai3KunOeLXQJ0ZGo%2FsGqtaAHJwt5t53qcokY7%2FTI0rnRBjV"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 872285f308b86404-LHR
alt-svc: h3=":443"; ma=86400

curl -I https://staging.bcgel.co.uk/wp-admin/
HTTP/2 302
date: Wed, 10 Apr 2024 11:51:15 GMT
content-type: text/html; charset=UTF-8
location: https://staging.bcgel.co.uk/wp-login.php?redirect_to=https%3A%2F%2Fstaging.bcgel.co.uk%2Fwp-admin%2F&reauth=1
x-powered-by: PHP/8.1.27
expires: Wed, 11 Jan 1984 05:00:00 GMT
cache-control: no-cache, must-revalidate, max-age=0
x-redirect-by: WordPress
x-static-config: yes
x-guest-hostname: vps-b8b949
vary: Accept-Encoding
x-via: LHR2
cf-cache-status: DYNAMIC
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=JR1SvvqJAEj0SVm2Rz%2FNnWusq7Ldo8YgLHaqMhXL0QC0Xpd5CWzNrg7wTjucU9OEuVpVdNPqXQRaxwf9%2BqoL27MdaRJqOyO24qQzBxjsuqIKYNyIxR7OvIy2KzldibEaiENSfjFl12SCDJ8WkDwcmQPM"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 8722860f2c1163b3-LHR
alt-svc: h3=":443"; ma=86400```

Hello.

This is because I applied a patch on wp-config.

define( ‘WP_HOME’, ‘https://staging.bcgel.co.uk’ );
define( ‘WP_SITEURL’, ‘https://staging.bcgel.co.uk’ );

But it shouldn’t need this.

If you want I can remove this and you can help me to sort this out?

I’m not quite clear what you are asking.

Are you saying the staging site is redirecting to live, but you don’t want that to happen

or

the staging site isn’t redirecting to live, but you want it to.

As above, the index page isn’t redirecting when I checked it.

Hello,

I don’t want to staging redirect to live. But its happening. So I went on google and I find a patch to resolve this, which is not recommended. It’s to put the following lines on wp-config file of the staging site.

Hello.

This is because I applied a patch on wp-config.

But when goes to staging site without this redirect to the live site.

You can try now and will see is redirecting as I remove these patches lines.

Hope could explain. :slight_smile:

Thanks

As before, no redirect on the home page. On the wp-admin page, there is again the Cloudflare redirect from /wp-admin to .../wp-admin/.

The redirect from staging to the live site happens in the next redirect and that’s still being done by Wordpress on your origin server…

curl -I https://staging.bcgel.co.uk/wp-admin
HTTP/2 301
date: Wed, 10 Apr 2024 12:19:24 GMT
content-type: text/html; charset=iso-8859-1
location: http://staging.bcgel.co.uk/wp-admin/
cache-control: max-age=0
expires: Wed, 10 Apr 2024 12:19:24 GMT
x-via: LHR1
cf-cache-status: DYNAMIC
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=Bf99g%2Bk4J7JFSzGLEuF9R6A6Ca9yGz2VlBXGDb6Ikqr%2F14%2BQgyOWgYbXrgA0gN6eqigLDUvJWt9JBqvQyXWJ7iIQYHaMoGbh0Iy0nBwGkEBlMb8kI62SBmaTNm%2FMv1ZOaD5yqaiZMOYCIh0N4wI6OEjP"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 8722af60bf304194-LHR
alt-svc: h3=":443"; ma=86400

curl -I https://staging.bcgel.co.uk/wp-admin/
HTTP/2 302
date: Wed, 10 Apr 2024 12:19:30 GMT
content-type: text/html; charset=UTF-8
location: https://www.bcgel.co.uk/wp-login.php?redirect_to=https%3A%2F%2Fstaging.bcgel.co.uk%2Fwp-admin%2F&reauth=1
x-powered-by: PHP/8.1.27
expires: Wed, 11 Jan 1984 05:00:00 GMT
cache-control: no-cache, must-revalidate, max-age=0
x-redirect-by: WordPress
x-static-config: yes
x-guest-hostname: vps-b8b949
vary: Accept-Encoding
x-via: LHR5
cf-cache-status: DYNAMIC
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=S%2FPXbuGfMc8GMG3YTSwjMv3on56niHthA1fBzNVCKBLRw4ppR9zWoRy5ttLKEilx6JK2jBZVveE%2B37BLl0KOsnh3wIx1fehcaBnw2C%2BZC6tdMFkZ8QKkNEeL0DaygRadhST9jqEyBl1Z0JsQnoy%2FmyYE"}],"group":"cf-nel","max_age":604800}
nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 8722af737d156323-LHR
alt-svc: h3=":443"; ma=86400

Thanks sjr.

And how to remove this redirect on wordpress in my origin server? I contacted them and they told is with Cloudflare.

Regards

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.