329: How to configure PrestaShop 1.5 with a Temp URL

Many people may want to build a new website while maintaining an existing one. An important reason for doing this is to be able to view and test the new site to ensure it will run correctly once the domain name is pointed to it. In many cases, the site owner may try to use a “Temp URL”, which is a URL that is used to view a site when the proper domain name is not pointed to it. It is typically long and usually contains a servername or number, and a username. They can appear quite cryptic and are typically only used for testing purposes.

Complex programs, such as PrestaShop, are reliant on the URL. This information is usually stored in more than one place, such as configuration files and one or more database tables, making it difficult to change from the Temp URL to the real domain name when the time comes.

Using a “Temporary URL” also may not be the best option due to the way a server, particularly an Apache server, reads path structures for things such as images, and CSS configuration files. If using a Temp URL, these may not work at all. Finally, there are many redirects that can affect areas such as admin logins, causing them not to work properly over a Temp URL.

While you may be able to modify settings and code to work well with the Temp URL, you will then need to undo all the settings once you point the domain to your new site.

There is another option that prevents all the back and forth work. This is known as a hosts file modification. Below are the steps to changing your hosts file to allow you to view your new website just as it would be if you already had your domain name pointed to it.

Be sure to back up the file onto a USB drive or copy it to another directory in case you need to restore it later.

Modifying your hosts file in Windows

Your hosts file will be in different places, denending on the version of Windows you are running:

  • Windows 95/98/Me c:windowshosts
  • Windows NT/2000/XP Pro c:winntsystem32driversetchosts
  • Windows XP Home/Vista/Windows 7 c:windowssystem32driversetchosts
Once you have located the file, open it in a text editor such NotePad. If you get a permissions error during the process, please check the link below for assistance:
https://support.microsoft.com/kb/923947

Your hosts file should appear something like the example below:

# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host

127.0.0.1 localhost

 
From there, you can add a new address to your file. For example:

70.39.145.13 YourRealDomainName.com
70.39.145.13 www.YourRealDomainName.com

Note that the IP address will be the one for your hosting server that stores your PrestaShop site. If you need help finding our your shared IP, follow our article here.

Modifying your Hosts file on a Mac

Changing your hosts file on a Mac must be done as the ‘root’ user in the Terminal application. Below are the steps you will need to take.

  1. Open the Mac’s Terminal application.
  2. Open the hosts file for editing. From the Terminal window, paste the code below intot he command string and hit Return.
    sudo nano /private/etc/hosts
  3. Edit the host by adding the following two lines to the end of the file:
    70.39.145.13 YourRealDomainName.com
    70.39.145.13 www.YourRealDomainName.com

    Be sure to use your servers’s shared IP address and your actual domain name.

  4. Save the changes to your file by pressing Control-o on the keyboard and then hit Return.
  5. You may need to flush your Mac’s DNS cache to see immediate changes. To do so copy the following code into the Terminal program and hit Return
    dscacheutil -flushcache

After you have changed your respective hosts file, restart your browser, and use your domain name to view your PrestaShop site.

4 thoughts on “329: How to configure PrestaShop 1.5 with a Temp URL

  1. Hi,

    In regards to this article on Prestashop and tempURL issues…

    Right now my live site is hosted on another host and my new working site is on InMotion Hosting — both hosts are using my real domain name and I am modifying my PC windows host, as stated above, so I can work on my working site. 

    Is there a way to set up and migrate my live site to InMotion Hosting too (while I build my working site)?  So I wish to have both, my live site and my working site on InMotion Hosting servers, but I do not want to use a temp URL on the working site.  I am using Prestashop on the working site.

    I thought that perhaps I could have two separate accounts with two different IPs, but tech support says that because of the nameservers I will not be able have the live site and the working site on two separate accounts with the same exact domain.com name.   

    Is there another solution?

    Thanks for your time.

    1. Hello Gg,

      You could migrate your live site to InMotion by going to the current live site and backing everything up. Then you could simply connect to our server and restore your shop to the same domain name on our server.

      When you wanted to access the site on our server, you would want to modify your hosts file to point to our server’s IP address. When you want to work on the live site, you would just comment out those lines in your hosts file by placing a # pound symbol in front of them.

      – Jacob

  2. Hello,

    I have a question. Afer you modify the host file, then what? how can I modify the website without changing the real one?

    Sorry if this a noob question, but I’m having many issues with it…

     

    Best regards,

    1. Hello Jcamos,

      After you modify your hosts file this will begin to resolve your domain name directly to our server. So if your domain was example.com, you could then just enter in https://example.com in your web browser and then you should be accessing your site directly from our server, even if your live DNS for that domain is still pointing at your previous host.

      To start editing your site, you would just login to your PrestaShop install on our server if you’ve already set one up. Or you could login to cPanel on our server and install PrestaShop with Softaculous if you haven’t installed it on our server yet.

      If you remove the entries from your hosts file pointing your domain to our server, then when you access https://example.com in your web-browser you will be accessing the site again from your live web host you still have DNS set to.

      When you are ready to point your domain to our server for real, you can go ahead and update your name servers to point to us.

      Please let us know if you had any other questions at all.

      – Jacob

Was this article helpful? Join the conversation!

Server Madness Sale
Score Big with Savings up to 99% Off

X