1 | 2 | 3

11

Virtual Hosts In Win98

Also relates to SEO

With Windows 98 as my primary OS on my current system, I have never really delved deep into Apache, except a previous failed attempt to establish Virtual Named Hosts. Well, today I returned to this with renewed vigour on reading Simon Willison's post and accompanying links on mod_rewrite. This voodoo is such a powerful feature for improved URI-security, search engine optimisation and usability. However, while I was able to play around with a few trial regular expressions on my test platform, conflict soon arose with the use of relative URIs in test builds to accomodate their directory location within subfolders of the root. So I decided it was time to finally get Name-based Virtual Hosts.

This was no easy feat - understandably there is little documentation online for Windows 98 and Apache! - and has taken a few hours to get to grips with. However while the solution may not be correct, it seems to work well now, and I can directly clone work-in-progress sites to the finished article. It also means I can take advantage of mod_rewrite safe in the knowledge that what I create on the test platform can be mirrored to the public server. Here are a few links that came in handy along the way:

The Windows 98 process boils down to:

  1. Edit the HOSTS file in the Windows home directory (C:\Windows\HOSTS - note the file HOSTS has no extension). Add a line for each name-based Virtual Host as follows:
    
    127.0.0.1    newhost

    The first entry will always be the same and the second the name of the new host. I found spaces were required between each field on the line rather than tabs.

  2. Add the new entry to httpd.conf (the Apache configuration file in the root directory of the web server) as follows:
    
    <VirtualHost *>
    ServerName newhost
    ServerAdmin webmaster@newhost
    DocumentRoot "C:/Apache/htdocs/newhost"
    </VirtualHost>
    

    Of course additional directives could be added to the Virtual Host, but in this case I am just accepting the defaults defined for the main server (ie localhost) in Section 2 of the config file.

I also found I needed to disable the Internet Connection in Internet Options of Internet Exploder to prevent the Connect window form popping up (annoying as much as anything). So by having two HOSTS files, one with the domain I am working on, www.tomwright.me.uk, pointed at the localhost, and one excluding the domain, I can work in the development environment on my test platform and transfer this as is to the public server without any issues relating to URI paths. And, of course, finally get to really play with mod_rewrite. A quick example being the following code in the .htaccess file at the root of a particular Virtual Host:


RewriteEngine On
RewriteRule solution/([a-z]+) /services.php?service=$1

Which cloaks the GET request for each service presenting a more usable and Search Engine friendly URI presented as a directory structure.

Perhaps one day I might actually trade in my Win98 and take the plunge into RHL….

Posted on Sep 03, 2003 at 01:39:23. [Comments for Virtual Hosts In Win98- 0]

Breadcrumbs Trail

[ Home ] -> TW Blog -> Apache
Site Map

The Severn Solutions website achieves the following standards:

[ XHTML 1.0 ] [ CSS 2 ] [ WAI AA ] [ Bobby AA ]

Page compiled in 0.079 seconds