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?