Page 1 of 1

Testing your files on the new server

Posted: Fri 17 Jun 2016 09:54
by David Gibson
for those migrating from britiac2 to britiac3...

Before you switch the DNS to point to the new server your new web pages are accessible as britiac3.miniserver.com/~username in "the usual way". However, for this to give you a proper view of your web site you must be using relative links, not absolute links. For example, you need to access your CSS file as (for example)

Code: Select all

<LINK REL="STYLESHEET" HREF="index.css">
and not

Code: Select all

<LINK REL="STYLESHEET" HREF="/index.css">
The reason for this is that any relative link will be interpreted as britiac3.miniserver.com/~username/somepage whereas an absolute link would be interpreted as britiac3.miniserver.com/somepage, which does not, of course, work.

It may be that your web site needs absolute links because of the way you have constructed it. That is certainly the case for me. In this situation you cannot test your site using ~username. Instead, the approach I have adopted, for my sites, is this...
  • In the DNS for your domain, create a sub-domain (e.g. newsite.mydomain.co.uk) that forwards to the IP address of the new server.
  • In the control panel for the new server, at http://britiac3.miniserver.com/cpanel, create a corresponding sub-domain for your site and specify the root location to be the same root as for your main site (so probably something like /home/username/public_html
Now you should be able to access your new site as newsite.mydomain.co.uk and all the links should work. To give public access to your new site, you just need to alter the DNS for mydomain.co.uk to also point to the new server.

Re: Testing your files on the new server

Posted: Fri 17 Jun 2016 10:42
by David Cooke
For those that don't have easy access to the DNS I have heard tell of a solution that involves /etc/hosts.

I've not tried it before now because I've always had easy access to the DNS.

It is simply to add a record for the test domain to /etc/hosts or /windows/system32/drivers/etc/hosts (on windows) on your local PC. The /etc/hosts file is checked before the DNS and therefore overrides it. So for the above example add a line:

Code: Select all

31.25.186.126       caving-library.org.uk
I just tried it and it works :D

Firefox needed a restart to recognise the change.

Re: Testing your files on the new server

Posted: Fri 17 Jun 2016 11:25
by David Gibson
Ah yes, Id completely forgotten about that. If you use this method, do not a) forget that you have made the setting, or b) forget that you didnt also make it on the laptop youre currently using - Past experiences !!!