httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ben Yau" <b...@cardcommerce.com>
Subject RE: [users@httpd] Subdomains of a hostname - possible?
Date Tue, 13 Jan 2004 17:12:22 GMT
A good guide is at the apache.org site itself.  There is a section "URL
Rewriting Guide"

http://httpd.apache.org/docs-2.0/misc/rewriteguide.html


Do you want ALL [string1] to be redirected to http://[string1].mymachine ?
or only if [string1] is a valid username (otherwise just load the actual
http://mymachine/string1 page ?

If the first is true (redirect everything), you can do something like
(untested)

RewriteRule   ^/([^/]+)/?(.*)      http://$1.mymachine/$2

$1 refers to the first set of parentheses (which matches all strings within
the first two slashes).

$2 refers to the second set of parentheses... so in the case of

http://mymachine/string1/thispath/thatpath
$1 = string1
$2 = thispath/thatpath
redirect wlil go to http://string1.mymachine/thispath/thatpath
(theoretically) :)

I'm guesing that this is actually not what you want but you want the second
case.  You only want the redirection to occur if string1 = valid username.
I haven't done this but if you look in the apache link I put at the
beginning I think you'll find info that'll help.  I'm guessing that the
"Webcluster through Homogeneous URL Layout" section of that documnt may
contain your answer.



Ben Yau

=================================
310.235.2500 x232
Card Commerce International, Inc.
http://www.cardcommerce.com
=================================


> -----Original Message-----
> From: Neil Freeman [mailto:neil.freeman@asa.co.uk]
> Sent: Tuesday, January 13, 2004 8:31 AM
> To: users@httpd.apache.org
> Subject: Re: [users@httpd] Subdomains of a hostname - possible?
>
>
> Thanks for the help. In the end I tracked the original problem down to
> our proxy server which was intercepting the page requests.
>
> I haven't touched RewriteRule or regular expressions very much. I don't
> suppose you know of the RewriteRule for rewriting the following:
>
> 	http://mymachine/[string]
>
> into
>
> 	http://[string1].mymachine
>
> I will continue googling but mod_rewrite looks pretty complicated!
>
> Neil
>
> Ben Yau wrote:
>
> > ***********************************************
> > This Email Has Been Virus Swept
> > ***********************************************
> >
> >
> >>I have a site whose pages contain absolute links for items such as
> >>pages, images, stylesheets etc.
> >>
> >>e.g.
> >>
> >>	<img src="/images/title.jpg" />
> >>
> >>This works fine if accessed from a proper domain (eg
> >>http://www.asa.co.uk) or from a subdomain (eg http://site1.asa.co.uk)
> >>
> >>I have an offline development system setup with LAMP with which I am
> >>attempting to setup subdomains which will work directly off
> that machine.
> >>
> >>What I would like users to be able to do is enter the following into
> >>their browser:
> >>
> >>	http://mymachine/site1/
> >>
> >>and have it access a local subdomain, eg
> >>
> >>	http://site1.mymachine
> >>
> >>The main virtual host I have setup for the machine is as follows:
> >>
> >>	<VirtualHost 192.168.1.138>
> >>		DocumentRoot /www.main/www
> >>		ServerName mymachine
> >>	</VirtualHost>
> >>	<Directory "/www.main/www">
> >>		AllowOverride All
> >>	</Directory>
> >>
> >>This works fine. I thought I could set up another virtual host for this
> >>new subdomain as follows but it doesn't work:
> >>
> >>	<VirtualHost 192.168.1.138>
> >>		DocumentRoot /www.site1/www
> >>		ServerName site1.mymachine
> >>	</VirtualHost>
> >>	<Directory "/www.site1/www">
> >>		AllowOverride All
> >>	</Directory>
> >>
> >>It doesn't matter if I have to setup/change hosts files as long as I can
> >>get the set up to work.
> >>
> >>Any suggestions as to how other people manage this would be greatly
> >>appreciated.
> >>
> >
> >
> > What exactly is not working?
> > Is it http://mymachine/site1 or http://site1.mymachin or both?
> > I'm guessing the first is not working but the second one is.
> You may have
> > to add a rewrite rule in to rewrite
> > http://mymachine/[string] to go to http://[string1].mymachine
> and then make
> > sure all your http://[string1].mymachine virtual hosts are set
> up correctly.
> >
> > Another way to do it is just do redirects
> >
> > create
> > http://mymachine/[string]/index.html
> > and in the index.html make a
> > <meta http-equiv="refresh" url="0;http://[string].mymachine">
> > Again you need to make sure http://[string1].mymachine is a
> valid virtual
> > host
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > The official User-To-User support forum of the Apache HTTP
> Server Project.
> > See <URL:http://httpd.apache.org/userslist.html> for more info.
> > To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> >    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> > For additional commands, e-mail: users-help@httpd.apache.org
> >
>
> --
> ----------------------
>   www.curvedvision.com
> ----------------------
>
>
>
> This communication is confidential to the intended recipient(s).
> If you are not that person you are not permitted to make use of
> the information and you are requested to notify the sender
> immediately of its receipt then destroy the copy in your
> possession. Any views or opinions expressed are those of the
> originator and may not represent those of Advanced System
> Architectures Ltd.
>
> *** This Email Has Been Virus Checked ***
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message