Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When developing WordPress websites, for instance, such a script saves a few values on the database with detected paths/addresses. To avoid issues when uploading the production version to the server (when the project is finished or updated) I normally setup my web development environment like this:

hosts file:

127.0.0.1 www.domain.com
127.0.0.1 domain.com

Apache virtual hosts file:

<VirtualHost *:80>
    DocumentRoot "C:\Users\Nazgulled\Workspace\World Wide Web\Htdocs\domain.com"
    ServerAlias www.domain.com
    ServerName domain.com
</VirtualHost>

And I'm done. I can access domain.com or www.domain.com like I was accessing the real server but I'm actually accessing my local development server.

However, I was wondering if I could this some other way... I mean, keep both domain.com and www.domain.com accessing the real server and something like http://domain acessing my local server. But in a way so that the WordPress script (or any other) detect the address as domain.com or www.domain.com and not simply as domain.

Any possible way to configure Apache virtual hosts for this kind of behavior? Besides that, do you have any other suggestions for a better virtual hosts configuration for local development simulating the real server location?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

if you use firefox there is quite a cool way:

SwitchHosts

https://addons.mozilla.org/en-US/firefox/addon/switchhosts/

there you can manage and switch between multiple host files.

for example: you create one production host file and one development host file. the production host file is empty so every domain is resolved by its real ip. the development host file has all your local lookup information inside.

Server Switcher

https://addons.mozilla.org/en-US/firefox/addon/server-switcher/

maybe also worth a try.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.