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:
# 220.127.116.11 rhino.acme.com # source server
# 18.104.22.168 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:
22.214.171.124 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
We value your feedback!
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
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.