Staging site not replacing few URL

I created a staging site but still a few URLs are pointing to the live site they are not replaced with the staging site’s URL.

  • Clent
    • Clent

    Hello

    After setting up a new staging environment, the following error popped up:


    Oops, the sync to staging for matinajewell.online has failed.

    In addition, the following error showed up on the new staging site’s wp-admin login page:


    Error 503 – Service Unavailable
    The server is currently unable to handle your request due to scheduled maintenance or a temporary overload.
    Please try again later or contact us if the problem persists.

    Your help in resolving the above issues would be greatly appreciated.

    Thanks

  • Kris Tomczyk
    • Support

    Hi Clent

    I hope you are doing good today.

    I was able to delete and create a fresh staging site of your live site.

    As for the main issue, when we create a staging site our system does not edit your files. We only move them between the live and staging folder. URLs are stored in database, and only there we run a script to search & replace URLs.

    You have a hardcoded live site URL in 3 files in your theme. Which is not common practice and it is not recommended.

    In your header.php file, you use your live domain URL 2 times.
    In your functions.php file, you use your live domain URL 8 times.

    Instead of your domain URL in those files, you should use:
    <?php echo get_site_url(); ?>
    https://developer.wordpress.org/reference/functions/get_site_url/
    So no matter does site is live, staging or move to other domain URLs, it will take the correct domain name. I recommend speaking with your developer to correct that part of your theme.

    Also your theme style.css use:
    background: url(https://your_domain_name/wp-content/themes/your_theme/images/buy-now.svg) no-repeat; which is absolute path.
    I recommend to correct that to relative path:
    background: url(/wp-content/themes/your_theme/images/buy-now.svg) no-repeat;

    As for now, if you’re not able to contact your developer I can only suggest to create an SFTP connection to the staging site and replace those paths, in those 3 files manually.

    Please note, if you will push staging changes to live site those staging URLs will be also moved. That is why I recommend solution nr 1:
    https://developer.wordpress.org/reference/functions/get_site_url/ for PHP files
    – relative path for an image in CSS file

    Kind Regards,
    Kris

  • Clent
    • Clent

    Hi kris

    Thank you for your response and for creating a fresh staging site.

    One of the reasons to migrate & host the live site on the WPMU server is to resolve all issues related to the old theme ( including hardcoded live site URLs in the 3 files ).

    The absolute path has been corrected to relative path in:

    – Additional CSS ( Appearance > Customise )
    – style.css
    – header.php
    – functions.php

    As the site home page is in the WordPress installation directory, the WordPress Address (URL): site_url() & Site Address (URL): home_url() are the same.

    In the header.php the $url is already defined as $url = get_home_url(); . So, I would appreciate if you could please clarify how replacing the get_home_url() with the get_site_url() would make any difference?

    In the functions.php there is only 1 line with the home_url() and the rest urls are related to woocommerce code. So, I would appreciate if you could please clarify how replacing the home_url() with the site_url() would make any difference?

    Your help with these issues is greatly appreciated.

    Many Thanks!

  • Kris Tomczyk
    • Support

    Hi Clent

    On our hosting and on most hostings there should be no difference. You can use:
    get_home_url() or get_site_url()
    home_url() or site_url()
    In this case: moving from staging and from staging to live site there is no point to change that. The main issues were the absolute path in files.

    Kind Regards,
    Kris

  • Clent
    • Clent

    Hi kris

    Thank you for your response and for your clarifications.

    Unfortunately, the absolute path must also be corrected to the relative path in all button links created by Elementor.

    Your help with these issues is greatly appreciated.

    Many Thanks!

  • Kris Tomczyk
    • Support

    Hi Clent

    From what I see access to the site (provided during chat session) does not work anymore. Please send the below data so I could take a closer look at this once again on live site and on staging site.

    Please send it through our secure contact form here https://wpmudev.com/contact/#i-have-a-different-question and make sure that subject is “I have a different question” and:
    – Mark to my attention: ATTN: Kris Tomczyk

    – Live site access:
    — login URL
    — username
    — password

    – Staging site access:
    — login URL
    — username
    — password

    – Link back to this thread

    Please don’t share any sensitive information (i.e credentials) in the Support Forum, it has public visibility and everyone will have access to it.

    Please confirm here in the thread that you have sent that message.

    Kind Regards,
    Kris

  • Clent
    • Clent

    Hi kris

    Thank you for your response.

    Now, there is a new safety policy in place that allows you to temporary login without login credentials, but only to the staging site ( not to the live site! ).

    As you are on Level 19 with 3,956 Rep Points, I made an exception and sent through the secure contact form. I have sent temporary admin login links with temporary admin access to the admin dashboards of both sites (live & staging).

    Special links to both sites, with a self-expiring personalised admin accounts have been sent only to you, with which you can login to the admin dashboards without needing admin usernames and passwords. ( This is only for you to use! )

    Your help is greatly appreciated.

    Many Thanks!

  • Kris Tomczyk
    • Support

    Hi Clent

    From what I see in both databases those URLs from Elementor are not stored there. I can only see one button on the home page called “BUY NOW”. I fix that on the staging site, but please note the Elementor force/suggest itself absolute path in those fields in edit mode. As I’m not familiar with this page this task will be out of scope and you will need to correct all those button URLs in all places. Only you know on which pages those buttons were added/used.

    Kind Regards,
    Kris