Forum Moderators: phranque
<VirtualHost *:80>
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/"
ServerName http://somesite.example.com/
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/anothersite/"
ServerName http://somesite.example.com/anothersite/
</VirtualHost>
I want to be able to assign a root directory to a url like
http://somesite.example.com/anothersite/
[edited by: jdMorgan at 6:53 pm (utc) on Dec. 3, 2008]
[edit reason] Please use example.com only. [/edit]
A DocumentRoot is assigned to a hostname (generally speaking, to a servername, virtualhost, or domain). So it's not clear how you want to "associate" your subdirectory (/anothersite) with a DocumentRoot; Technically, /anothersite is a child subdirectory of the document root directory in the domain from which /anothersite is requested.
It might be helpful to back up one step, and describe what your goal is -- What are you trying to accomplish?
Jim
So for instance id like when you go to
http://example.com/anothersite/
C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/anothersite/was the root and not
C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/
<a href="/about/">about</a>
http://example.com/about/
http://example.com/anothersite/about/
I realize what Im trying to do may not be possible or may not even be logical. Im just trying to set up a new vhost for each client i get and looking for the most cost effective way to do so.
I know I could use another free service to set up free unlimited sub domains and that seems to work, but that means ill need to at least purchase one name 1st.
/home/projects
/home/projects/client1
/home/projects/client2
/home/someOtherFolder/anotherFolder/client3
... the following vhost can be been created:
<VirtualHost *:80>
DocumentRoot /home/projects/
ServerName myserver.localhost
Alias /client1 /home/projects/client1
Alias /client2 /home/projects/client2
Alias /client3 /home/someOtherFolder/anotherFolder/client3
</VirtualHost>
From that, you can probably see that the following urls will point to the following locations:
myserver.localhost -> /home/projects
myserver.localhost/client1 -> /home/projects/client1
myserver.localhost/client2 -> /home/projects/client2
myserver.localhost/client2 -> /home/someOtherFolder/anotherFolder/client3
More on host aliases here ...
[fancybread.com...]
Hope this helps. Good luck!
<VirtualHost *:80>
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
ServerName [mydomain.org...]
Alias /anotherdomain.com "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/anotherdomain.com"
</VirtualHost>
Can you see what I need to do here to make this work?
1) Remove the Alias for now, so that you only have a DocumentRoot and ServerName
2) Verify mydomain.org is in your hosts file
3) Restart Apache
Can you hit [mydomain.org?...] If not, then you need to debug your virtual host first.
I can hit [mydomain.org...] so i know thats working..
Jim
<a href="/about/">about</a>
was linking to
something.mydomain.org/about
and not
something.mydomain.org/client1/about
I wanted it to treat
something.mydomain.org/client1/
as the root even for linking in the html and css
this way when i upload and go live to the main server I dont have to change the html and css linking from
<a href="/client1/about/">about</a>
to
<a href="/about/">about</a>
Is there any way to make this happen by changing the vhosts or anything in apache? Is this just not the way it works?
Am I better off using sub domains on my home server for setting up new client test environments such as
client1.mydomain.org
client2.mydomain.org
client3.mydomain.org
And even better would be to define a VirtualHost per client, and fully-emulate the domain.
Basically, you want your development and test servers set up exactly the way the client's server is set up. This takes some work at the front end of a project, but can save enormous amounts of time later. It also prevents potentially-very-nasty surprises when moving from test to production (a time when the client is likely impatient and watching you very closely).
Jim
purchase a domain name for 10 bucks that is something general that represents my home server (like "homeserver.com")
use zoneedit to set up unlimited sub domains for each client (like "clientz.homeserver.com")
assign a new vhost for each client
is there another way to do this without purchasing a domain name and using zone edit? is there some way to do this in apache
its important for clients to be able to see the test environment from the outside, so i cant just use localhost
Define any and all the domains you like in the hosts file as pointing to 127.0.0.1 on your server machine. On all other machines in your network, use their host files to define those same domains as pointing to the LAN IP address of your server, e.g. 192.168.0.10)
The hosts file acts as a simple DNS server on each of these machines; Any entry found in the hosts file will override and prevent the DNS requests of any and all internet-capable programs on your machine. Therefore, you are effectively running a 'private DNS server' on each of these amchines, and you can define any domain you like, whether it is registered or not.
For example, if you put "127.0.0.1 www.google.com" in your hosts file, then you can set up ServerName www.google.com in a vHost container, and pretend you are Sergey Brin... :)
Only in the case where you want people from outside your network to be able to access these servers by domain name do you need to worry about registering the domain names. And in that case, you could very well set up reverse proxies from a public domain of client-subdomain.youronedomain.com to clientname.com inside your network.
When you finish testing and take a site live on a public server, simply delete the relevant entries from your hosts files, so that your machines will then use the public DNS system to resolve these domains' IP addresses.
HTH,
Jim
[edited by: jdMorgan at 9:24 pm (utc) on Dec. 5, 2008]
In firefox and Ie7 I get
Error 400 - Bad Request
when i try to hit client1.myserver.com
but using ie6 its fine,
also while i was out at the coffee shop i could hit
client1.myserver.com
just fine.
furthermore my cell phone browser can hit
client1.myserver.com
just fine
is this temporary and i just need to wait? is there some kind of internal network issue going on here?