Why is WordPress rewriting absolute URLs on staging site to include staging prefix when we manually point them at the live site?

Question

Edited for clarity and to display steps we take to reproduce the issue.

Question

What would cause absolute URLs on our staging site to prepend the staging site’s subdomain to them when saved in the editor?

Summary

We write pages manually in HTML and CSS on a staging site hosted on SiteGround, save our changes, then test them. However, when we save our work in the editor, they all prepend the staging subdomain we are writing on to each of the absolute URLs we’ve written.

Steps to Reproduce

  1. Create a staging copy of the live site.
  2. Disable all plugins.
  3. Install and activate the twenty nineteen default theme from WordPress.
  4. Create a new page, title it whatever you want.
  5. On that page, create four links:
    a. http://example.com
    b. http://www.example.com
    c. https://example.com
    d. https://www.example.com
  6. Save the page.
  7. View the page – all links point to https://stagingX.example.com
  8. Edit the page – all links will have had “stagingX.” prepended to them, showing that they have been rewritten.

Detailed Breakdown

We write a link destination as an absolute URL into a page, like this example:

“Click here for our <a href="https://example.com/daily-specials">Daily Specials</a>!”

We then save our work in the editor.

If we immediately check the link on the staging site, it is already pointing instead to <a href="https://staging.example.com/daily-specials"></a> and displays as such if we relaunch the editor.

While this does not affect any relative URLs (i.e. <a href="/daily-specials"></a>), it does affect every prefix variant of absolute URLs.

The site has thousands of absolute URLs affected by this.

What We’ve Tried

We must be missing something, so please feel free to offer any guidance or perspective, regardless of whether it seems redundant or not.

We’ve attempted checking the server, theme, and child theme .htaccess and functions.php files in cPanel for any code that would cause this (perhaps we missed or misunderstood it?).

We’ve also verified that the site URL etc. under Settings > General in the WordPress dashboard are pointing at the live site without the staging prefix.

We have disabled all plugins and switched to the Twenty Nineteen theme and experience the same issues.

The Home URL and Site URL in settings and in the database are set to the main site, but in the help section of the “Better Search Replace” plugin it shows both URLs as having the staging subdomain preceding them.

0
Caleb Mieszko 4 months 0 Answers 15 views 0

Leave an answer