Apache Server configuration support - Virtual Hosting and Subdirectories with IP

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > November 2006 > Virtual Hosting and Subdirectories with IP





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Virtual Hosting and Subdirectories with IP
billy

2006-11-06, 7:27 pm

ok, i have 2 local websites , WEB1 and WEB2.

i want to access them like this

http://192.168.4.16/web1 and http://192.168.4.16/web2

I want Web1 to redirect to a specific directory, and web2, another one.

<VirtualHost *:80>
DocumentRoot "/home/web1"
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "/home/web2"
</VirtualHost>

Any idea how to do it?

I dont want to use the HOSTS files because i want it to be available
from the outside

Thanks in advance

shimmyshack

2006-11-07, 1:31 am


you have a few options depending on what you mean...
however you /could/ just write your websites so that your links are all
of the form /web1/js/code.js and /web2/js/code2.js
that would work. Isnt very sexy thats all. You could write all your
code with relative links.
send web1/index.html which has links of form
js/code.js and img/image1.png (notice no leading /) files in later dirs
could have ../ to refer back to just below web1/ it would all work fine
and you could move it around all over the place.

if you want _everyone_ to be able to get it, then you could try dyndns
service, its pretty good.
If you control the people who will be looking you can ask them to put a
line in their hosts file.

If you write your own webcode you could use XHR requests and add the
relevant host header in order to use a sensible header, and set up
vhosts on your system OR you could make sure all your HTML contained
the base element. (not sure if thats accepted in xhtml-strict though -
but my guess is that you arent sending xhtml strict as application
xhtml/xml anyway)
You could use apache2 request header functionality to add the host
header based on whether the end number of the first part of the url was
1 or 2, (I havent checked to see whether the host header will be
honoured after it being set at that point) - thats is an interesting
one!
You could use two separate ports, 81, and 80. This is probably the
easiest set up.
else yeah sure you could use the rewrite cond, if first part of url is
web1 then rewrite all urls internally, this costs in terms of processor
power though.

the way you have set it up at the moment, if you set the doc root to be
web1/ then the next request to come back from the client that contained
/web1 would go to web1/web1, which doesnt exist...

the docs are pretty good on rewrites, and the other ideas are covered
there too.

Davide Bianchi

2006-11-07, 1:31 am

On 2006-11-06, billy <ginguene@gmail.com> wrote:
> http://192.168.4.16/web1 and http://192.168.4.16/web2
> I want Web1 to redirect to a specific directory, and web2, another one.


Alias /web1 /wherever/you/want/them
Alias /web2 /wherever/you/want/them2

See the documentation of Alias.

Davide

--
Best viewed with Internet Explorer 5.6 on a 1280x1024 resolution with
24-bit color depth, maximum contrast, minimum brightness, in a 1000x960
window placed in the exact center of your display with this videocard
and ....
-- from alt.sysadmin.recovery
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com