I think there's a little mis-understanding here. Clean URLs are used to provide simpler, easier to understand URLs that search engines would prefer. Making a HOSTS file mod does NOT hack the site or change anything about a website. It simply makes it easier for you to deal with the issue of developing using the actual domain name.
Yes, I understand that you have a live site. If you make a HOST file modification, you can designate one of your URLS - I was suggesting the WWW version, so that ONLY your computer would recognize that the URL is resolving to our hosting computer here. The "temporary URL" is simply another URL that can be used to get to the domain hosted with us. You are stating that you want to enable "clear URLs" -also called search engine friendly URLs. The problem with setting up the temporary URL on your site is that when you do so, ALL of the URLs being generated for your temporary site will require that temp URL. Then when you're finished with it and ready to go live, you'll need to go and change the configuration files and possibly the database with the live URL. This will only cause you more work.
This is not a hack - web developers use it all the time to make their lives easy when developing a site. It enables you to use the actual LIVE url at your desktop. Making a host file modification means that only YOU (or anyone on your computer) will see that particular URL resolving to the server here.
Let's say your live domain name is domain_name.com
The web browser can resolve that domain name to either (a typical web server is configured to recognize either URL):
And by default, the browser KNOWS that the URL goes to a particular server on a different hosting service. To illustrate how a HOSTS file modification works we'll make up an imaginary IP address like 18.104.22.168. The IP for your site here will be 456.456.456.456. Currently when you type in domain_name.com, the site will go to 22.214.171.124. However, with a hosts file mod you can change where a particular URL resolves to, but only for your computer.
You can literally change the IP location for www.domain_name.com to someplace else. So what will happen is this:
domain_name.com goes to 126.96.36.199
www.domain_name.com goes to 456.456.456.456 (after the HOSTS file modification)
This means that you can use the actual LIVE domain name (albeit with "www") on your computer to go to the development server. Again, this is would only resolve to that IP address on the computer where you make the HOSTS file modification. You can then turn ON the "clean URLs" and instead of something like:
Your URL will look like: http://www.domain_name.com/menu-to-something.
And that is what you're trying to ultimately accomplish. Basically, ignoring all this long-winded explanation of what a HOSTS file mod does, I'm trying to save you some steps (and headaches of editing your config or database). I do understand what you're trying to accomplish, and using the hosts file you can definitely do this. Hosts file mods are simple one-line edits. You can apply and then remove it any time. It's not a "hack" but a useful option that you can easily make so that you can define where certain URLs will go.
If after all of this, you still want to the temporary URL, you will need go into the files for your Drupal installation, find the SITES folder, determine the site you are using (if you have more than one), select that folder, and then edit the SETTINGS.PHP file. You would need to change/enable the BASE URL there and change it to the temp URL. By default, the BASE URL line is typically disabled. You will see it commented out with a "#" in front of the line. We recommend that you do NOT make any posts or references to graphics when you're using the temp URL. This is to prevent possible entries that use the temp URL because you would be changing that URL to something else when you go live.
When you go live, you would then simply change the BASE URL setting to the real URL (or make it a comment again by adding the "#" sign).
We have been suggesting to use the HOSTs file modification in these cases in order to prevent making unnecessary changes to settings or configuration files for your application installation. This helps to prevent possible confusion and possible file path issues when the site goes live. However, it is your choice!
I hope this helps to clarify what a Hosts file mod does. I have also provided the information you need to change the Base URL for your Drupal installation.
2013-09-19 6:15 pm EST