Mobile app version of vmapp.org
Login or Join
Shelley277

: How to safely replace live site (without database) with staging site using Apache shared hosting? I have a PHP website of around 20 pages without a database on shared hosting - it has quite

@Shelley277

Posted in: #BestPractices #Publishing #SharedHosting

I have a PHP website of around 20 pages without a database on shared hosting - it has quite a lot of forms and a significant amount of visits. I have a staging subdomain on the same server wherein I have uploaded a new version of the site.

I want to replace the live site with the staging site, but I am worried if it will cause any errors or inconveniences to the users, for example those who have just clicked the submit button on a form, or any other case in general.

One option I know of is to simple copy everything from the staging site to the live site directory, and replace the old site. But I don't know how it will affect the users currently online, and it may have some consequences I am not aware of.

I think a safer approach would be to block new users from entering the site (I think it can be done using the .htaccess file), and then ensure all of the users have exited, or somehow force them to exit the site, before replacing the live site with the staging site.

Is there a better method than the above? If not, how would I make sure all of the users have exited the site before replacing it with the new one?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Shelley277

1 Comments

Sorted by latest first Latest Oldest Best

 

@LarsenBagley505

Copying the site from one folder to the next is a good start.

Next if you use a content management system, check any configuration files that contain path names (or folder names) and update them to match the correct path names for the new domain you move your site to.

If you written code manually, after copying it over check all links in the code itself to make sure they point to the correct URLs on the new domain.

For example, if you have code that contained:

<a href="http://old.com/123">


You would change it to something like:

<a href="http://new.com/123">


Except you replace old.com and new.com with the correct old domain name and new domain name respectively.

Then clear the cache in your browser and test everything on the new URL and watch the address bar of your browser as you test to make sure the old domain does not reappear again.

When that's all done, then on the old domain, set up .htaccess so that any request to any old URL is redirected to the new URL.

These lines places in .htaccess should help provided your server is apache with mod_rewrite module installed and active.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.olddomain.com$ [NC]
RewriteRule ^(.*)$ www.newdomain.com/ [R=301,L]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme