[SLUG] .htaccess files

Gavin Baker gav at supercowpowers.org
Fri Aug 29 01:48:00 BST 2003


Hi Mark,

I don't think I have a solution, but maybe some useful suggestions.

On Fri, 2003-08-29 at 00:26, Mark Feather wrote:
> You need to enter a line into the Hosts file:
> 
> 127.0.01    akwe.freeshell.org  (i can also use the IP address of the NIC)

You mentioned that the box is on a LAN, so it might be neater to instead
add another IP to the Ethernet interface, and use that IP in your static
hosts file, and let apache listen on that instead.

ie,
	ip address add 192.168.0.69 dev eth0
(or)	ip a a 192.168.0.69 dev eth0
(or)	ifconfig eth0:1 192.168.0.69

and add "192.168.0.69   akwe.freeshell.org" to /etc/hosts

I don't know how your LAN DNS is set up, but if any machine replies to a
query asking for akwe.freeshell.org and is told it's at 127.0.0.1, the
querying machine will try connect to its own loopback device.

> then add the following into Apache's configuration file:
> 
> ServerName akwe.freeshell.org
> 
> <VirtualHost akwe.freeshell.org>
> 
> DocumentRoot /www/ag/a/akwe (path to html root directory)
> ServerName akwe.freeshell.org
> 
> </VirtualHost>
> 
> this has sorted out my DocumentError problem but it has created 2 other
> problems to resolve......
> 
> Using the Virtual URL address on the linux box the server displays pages in
> the correct location but cannot find my users cgi-bin!   It can find it
> using the localhost address though.   The servers error log reads: invalid
> CGI ref "../cgi-bin/bcu/counter.pl" in /www/ag/a/akwe/bcu/index.shtml   Any
> thoughts and ideas?  I guess i have to add content between the VirtualHost
> container or alter my config file somewhere else but where?

Try a ScriptAlias directive inside your virtual host, like

<VirtualHost akwe.freeshell.org>	
	ServerName akwe.freeshell.org
	DocumentRoot /www/ag/a/akwe
	ScriptAlias /cgi-bin/ /www/ag/a/akwe/
</VirtualHost>

If you don't use a ScriptAlias inside the vhost, the global /cgi-bin/
will be used, wherever thats aliased to.

You can also keep a log just for this vhost separate from the others
with something like

	CustomLog /www/ag/a/akwe/akwe.log full	

inside the <VirtualHost />.

> My windows machine can find the website using the ip address of the linux
> box in the URL address and cgi scripts run correctly but when i use the
> virtual address all i get is a std ie error page "page cannot be displayed"!
> Any thoughts and ideas welcome.

If you have the vhost listening on 127.0.0.1 (The virtual loopback
device, which isn't a real network interface so doesn't listen on any
networks), no machine other than localhost will be able to connect to
it. 

If you change it to a valid IP, the windows box will be able to connect
to the site via it's IP address. 

There might be a problem with the windows machine not resolving the
virtual host's hostname though. Do you use a DNS server or a
masquerading one your LAN? Is there a static hosts file on windows?

Also, would it not be possible to just build your site using relative
links?

ie, instead of 

	<a href="akwe.freeshell.org/index.html">home</a>

use
	<a href="/index.html">home</a>

You can use regular unix file system style relative paths too.

Doing this would mean it makes no difference where your website is
hosted. It will just work. Even if it wasn't in the DocumentRoot


Good luck,

Gav

-- 
Gavin Baker <gav at supercowpowers.org>





More information about the Scarborough mailing list