[lug] Apache Virtual Hosting Question

Zan Lynx zlynx at acm.org
Thu Apr 4 09:04:56 MDT 2019


On 4/3/19 6:19 PM, D. Stimits wrote:
> I ran into a case where I wanted to test a couple of independent web
> "creations" on my Fedora system. So I set up virtual names, and my
> "/etc/hosts" has a couple of different domains. The content is in
> different subdirectories of "/var/www/". Within the actual html/css I'm
> trying to learn to a bit more modern, and so for example I've referred
> to some URLs via the
> "//use/the/requesting/protocol/instead/of/hard/coding/" syntax. Only
> this doesn't work for external CSS.
> 
> 
> If I don't actually code the explicit name into the URL it doesn't work.
> I didn't want to do mod_rewrite, but I did want to html/css to be
> portable without embedding a host name into it. Should I be running more
> than one server instance on different ports instead of working with
> virtual servers?
> 
> 
> I would hope that if I refer to a site as "http://custom", and "custom"
> is in "/etc/hosts", that any relative URLs in the html would also assume
> that "custom", but it doesn't seem to be the case.

I beleive that if you want to use a different host name but keep http or
https the same you need to use a URL like ://new-host/path/file.css

The colon is important, you can't leave it out. A URL that starts with a
slash is relative to the host of the current page. And of course a URL
that starts without any slash is relative to the directory of the
current page.

-- 
                Knowledge is Power -- Power Corrupts
                        Study Hard -- Be Evil


More information about the LUG mailing list