This article describes one example to use Apache’s mod_rewrite to solve typical URL-based problems webmasters might be usually confronted with in practice.
Firstly, load ‘mod_rewrite’.
Open conf/httpd.conf, find ‘Dynamic Shared Object (DSO) Support’.
input :
LoadModule rewrite_module modules/mod_rewrite.so
mod_rewrite is sophisticated and powerful module.
With it webmasters can nearly do all types of URL manipulations ever dreamed about. The price have to pay is to accept complexity.
Secondly,configue URL Layout.
Canonical Hostnames
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.[^.]+
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^www\.([^.]+)(.*) http://$1$2 [L,R]
Thirdly,Configure how the server determines its own name and port.
With UseCanonicalName Off Apache will form self-referential URLs using the hostname and port supplied by the client if any are supplied (otherwise it will use the canonical name, as defined above). These values are the same that are used to implement name based virtual hosts, and are available with the same clients. The CGI variables SERVER_NAME and SERVER_PORT will be constructed from the client supplied values as well.
UseCanonicalName Off
VirtualDocumentRoot “C:\www\%0\html”
<Directory “C:\www\*\html”>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
VirtualScriptAlias “C:\www\%0\cgi”
<Directory “C:\www\*\cgi”>
Options None
Order allow,deny
Allow from all
</Directory>
Fourthly,modify the hosts file in desk machine(winxp).
windows/system32/drivers/etc/hosts.
Add:
127.0.0.1 localhost
127.0.0.1 test.com.au
127.0.0.1 my.company.com.au
Finally, build application directories.
C:\www\test.com.au\html
C:\www\my.company.com.au\html
when your type test.com.au, you can visit the test.com.au application hosting in C:\www\test.com.au\html.