[TriLUG] apache redirect

Rick DeNatale rick.denatale at gmail.com
Thu Jan 19 20:32:45 EST 2006


On 1/19/06, William Sutton <william at trilug.org> wrote:
>
> What happens if you try
>
> <VirtualHost *:80>
>          RewriteCond  %{REQUEST_URI}    ^/somedir*      [C]
>          ServerName   foo.com                           [L]
>          Redirect 301 /                 http://bar.com/
>          ServerName   foo.com
> </VirtualHost>
>
> basically....no matter what the host is, if the REQUEST_URI begins
> /somedir*, chain to the next rule, which sets ServerName and leaves the
> rewrite block...

I don't think that this works.  The ServerName directive is not a
RewriteRule. It's declarative, not 'executable'.  It's used witin a
VirtualHost block in a namebased virtual host setup to determine which
hostnames the virtual host block applies to.  I'm pretty sure that it
can only appear once in a vhost block, or in the overall server
configuration if you're not using name based virtual hosts. There's a
ServerAlias directive to allow for additional incoming hostnames for
the same (v)host.

Perhaps another thing to try would be to setup a document root for
foo.com which contained only the somedir directory and use the
ErrorDocument directive to do the redirect, possibly through a cgi
script

I'm doing something related, I've got several virtual hosts, one of
which is running a wiki, the others redirect requests to a
non-existent /wiki/... uri to the wiki virtual host by using
ErrorDocument to send 404 errors to a php script, the idea I used here
came from:
http://www.onlamp.com/pub/a/onlamp/2003/02/13/davidsklar.html

--
Rick DeNatale

Visit the Project Mercury Wiki Site
http://www.mercuryspacecraft.com/



More information about the TriLUG mailing list