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:\windows\hosts
- Windows NT/2000/XP Pro c:\winnt\system32\drivers\etc\hosts
- Windows XP Home/Vista/Windows 7 c:\windows\system32\drivers\etc\hosts
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:
Your hosts file should appear something like the example below:
# 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
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
# For example:
# 22.214.171.124 rhino.acme.com # source server
# 126.96.36.199 x.acme.com # x client host
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.
- Open the Mac's Terminal application.
- 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
- Edit the host by adding the following two lines to the end of the file:
188.8.131.52 YourRealDomainName.comBe sure to use your servers's shared IP address and your actual domain name.
- Save the changes to your file by pressing Control-o on the keyboard and then hit Return.
- 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
‹Section 12: 330: Setting up the Cross Selling module in PrestaShop 1.5
›Section 14: 345: Setting up the customer loyalty program module in PrestaShop 1.5
2014-04-03 3:58 pm
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...
2014-04-03 4:36 pm
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 http://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 http://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.
2014-07-03 8:36 pm
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.
2014-07-03 8:44 pm
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.