httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Noah <>
Subject Re: [users@httpd] using mod_rewrite for subdirectories
Date Mon, 04 Apr 2005 22:15:41 GMT
On Mon, Apr 04, 2005 at 02:35:08PM -0700, Octavian Hornoiu wrote:
> Hi, I am new to using mod_rewrite but I have used apache extensively in
> the past.  I am interested in redirecting sub-directories to a host name
> in the same domain.  Here is an example:
>  >
> Here is another example:
> >

Assuming I understand what you're going for here...

RewriteEngine on
RewriteRule ^/([^/]+) http://$ [L,R]

This will capture the first part of the URL path and use it as the
hostname in your domain. It will NOT, in this form, add any other
pathing info; you *could* have something like this:

RewriteEngine on
RewriteRule ^/([^/]+)(/.*)? http://$$2 [L,R]

...which would append any of the URI path data *after* the initial part
to the the target. This may or may not be in keeping with what you have
in mind, but I figured I'd toss it out there.

> Also, how do you place multiple rulesets and redirects in the same
> virtual host container?  If i want to redirect 20-30 of these
> sub-directories how do I list them in the ruleset?

Well, if it's always going to be the case that maps to, the above rule will handle all the cases. If
there are other cases that need handling, you can add rules for them;
note that order *may* matter, depending on the nature of the rules.


"Any system shall not harm your content or, through 
inaction, allow your content to come to harm."
                            - Jeff Raskin

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message