httpd.conf: redirect from one host to another?

httpd.conf: redirect from one host to another?

Post by David Steube » Thu, 10 Aug 2000 04:00:00



I have two names for the same domain:  collegeskin.com and
college-skin.com.  I am using name based virtual hosting.

The server is not on the Internet yet, so I am configuring it on a
private IP network.  What I want is a rule in httpd.conf that
redirects a request to www.college-skin.apostrophe to
www.collegeskin.apostrophe unconditionally. (the word apostrophe will
be replaced with com when the machine is moved).

Anyway, the second VirtualHost directive doesn't do the trick.  Any
ideas?

<VirtualHost 10.7.7.11>
        ServerName www.collegeskin.apostrophe

        DocumentRoot /websites/collegeskin.com
        ErrorLog /weblogs/collegeskin.com/error_log
        TransferLog /weblogs/collegeskin.com/access.log
</virtualHost>

<VirtualHost 10.7.7.11>
       ServerName www.college-skin.apostrophe
       ServerAlias www.collegeskin.apostrophe
       Rewri*gine On
       RewriteRule www.collegeskin.apostrophe - [R]
</virtualHost>

--
David Steuber   |   Hi!  My name is David Steuber, and I am
NRA Member      |   a hoploholic.
http://www.veryComputer.com/

The problem with AI is that it has a mind of its own
        --- Devon Miller

 
 
 

httpd.conf: redirect from one host to another?

Post by dcd.. » Thu, 10 Aug 2000 04:00:00




> I have two names for the same domain:  collegeskin.com and
> college-skin.com.  I am using name based virtual hosting.

> The server is not on the Internet yet, so I am configuring it on a
> private IP network.  What I want is a rule in httpd.conf that
> redirects a request to www.college-skin.apostrophe to
> www.collegeskin.apostrophe unconditionally. (the word apostrophe will
> be replaced with com when the machine is moved).

> Anyway, the second VirtualHost directive doesn't do the trick.  Any
> ideas?

> <VirtualHost 10.7.7.11>
>         ServerName www.collegeskin.apostrophe

>         DocumentRoot /websites/collegeskin.com
>         ErrorLog /weblogs/collegeskin.com/error_log
>         TransferLog /weblogs/collegeskin.com/access.log
> </virtualHost>

> <VirtualHost 10.7.7.11>
>        ServerName www.college-skin.apostrophe
>        ServerAlias www.collegeskin.apostrophe
>        Rewri*gine On
>        RewriteRule www.collegeskin.apostrophe - [R]
> </virtualHost>

> --
> David Steuber   |   Hi!  My name is David Steuber, and I am
> NRA Member      |   a hoploholic.

http://www.veryComputer.com/
Look+it+up

Quote:

> The problem with AI is that it has a mind of its own
>    --- Devon Miller

Why not just redirect the page with javascript instead of messing with
the conf file?
Try this.

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
window.location="http://www.veryComputer.com/
ge.html";
// End -->
</script>

Sent via Deja.com http://www.veryComputer.com/
Before you buy.

 
 
 

httpd.conf: redirect from one host to another?

Post by aceinter.. » Thu, 10 Aug 2000 04:00:00


To alias them...

 <VirtualHost 10.7.7.11>
         ServerName www.collegeskin.apostrophe

         ServerAlias www.college-skin.apostrophe
         DocumentRoot /websites/collegeskin.com
         ErrorLog /weblogs/collegeskin.com/error_log
         TransferLog /weblogs/collegeskin.com/access.log
 </virtualHost>

To redirect...

<VirtualHost 10.7.7.11>
         ServerName www.college-skin.apostrophe
         Redierct / http://www.collegeskin.apostrophe

         DocumentRoot /websites/collegeskin.com
         ErrorLog /weblogs/collegeskin.com/error_log
         TransferLog /weblogs/collegeskin.com/access.log
 </virtualHost>

This should do the trick

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

httpd.conf: redirect from one host to another?

Post by Bill Mosele » Thu, 10 Aug 2000 04:00:00



steuber.com) remarked...

Quote:> I have two names for the same domain:  collegeskin.com and
> college-skin.com.  I am using name based virtual hosting.

> The server is not on the Internet yet, so I am configuring it on a
> private IP network.  What I want is a rule in httpd.conf that
> redirects a request to www.college-skin.apostrophe to
> www.collegeskin.apostrophe unconditionally. (the word apostrophe will
> be replaced with com when the machine is moved).

For fun you can read http://www.veryComputer.com/
(if you like) while testing.

Quote:> Anyway, the second VirtualHost directive doesn't do the trick.  Any
> ideas?

You didn't post your NaveVirtualHost directive.

You also have a ServerAlias for the second that matches the first.  You
can't have two different name-based servers with the same name, of
course.

Do you really want to redirect or just allow both to be served by the
same virtual host?  If the second, then you don't need two different
virtual host setups.  Just use ServerAlias.

> <VirtualHost 10.7.7.11>
>         ServerName www.collegeskin.apostrophe

>         DocumentRoot /websites/collegeskin.com
>         ErrorLog /weblogs/collegeskin.com/error_log
>         TransferLog /weblogs/collegeskin.com/access.log
> </virtualHost>

> <VirtualHost 10.7.7.11>
>        ServerName www.college-skin.apostrophe
>        ServerAlias www.collegeskin.apostrophe
>        Rewri*gine On
>        RewriteRule www.collegeskin.apostrophe - [R]
> </virtualHost>

--
Bill Moseley
 
 
 

httpd.conf: redirect from one host to another?

Post by David Steube » Thu, 10 Aug 2000 04:00:00


' To redirect...
'
' <VirtualHost 10.7.7.11>
'          ServerName www.college-skin.apostrophe
'          Redierct / http://www.collegeskin.apostrophe

'          DocumentRoot /websites/collegeskin.com
'          ErrorLog /weblogs/collegeskin.com/error_log
'          TransferLog /weblogs/collegeskin.com/access.log
'  </virtualHost>
'
' This should do the trick

Thanks.  That only redirected /, but I found RedirectMatch and I think
I got the regexp right.

--
David Steuber   |   Hi!  My name is David Steuber, and I am
NRA Member      |   a hoploholic.
http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=hoplite&subm...

The problem with AI is that it has a mind of its own
        --- Devon Miller

 
 
 

httpd.conf: redirect from one host to another?

Post by David Steube » Thu, 10 Aug 2000 04:00:00


' For fun you can read http://www.veryComputer.com/
' (if you like) while testing.

The domain names work fine as they are (they are in the /etc/hosts file).

' > Anyway, the second VirtualHost directive doesn't do the trick.  Any
' > ideas?
'
' You didn't post your NaveVirtualHost directive.

I don't know that directive.  I have this directive:

NameVirtualHost 10.7.7.11

' You also have a ServerAlias for the second that matches the first.  You
' can't have two different name-based servers with the same name, of
' course.

I'm aware.  Perhaps you can elucidate on ServerALias.  I thought I was
following the example in ``Professional Apache'' correctly.
Apparantly not.

' Do you really want to redirect or just allow both to be served by the
' same virtual host?  If the second, then you don't need two different
' virtual host setups.  Just use ServerAlias.

I really want to redirect.  As in send the client a 302 with a
Location header.

' >
' > <VirtualHost 10.7.7.11>
' >         ServerName www.collegeskin.apostrophe

' >         DocumentRoot /websites/collegeskin.com
' >         ErrorLog /weblogs/collegeskin.com/error_log
' >         TransferLog /weblogs/collegeskin.com/access.log
' > </virtualHost>
' >
' > <VirtualHost 10.7.7.11>
' >        ServerName www.college-skin.apostrophe
' >        ServerAlias www.collegeskin.apostrophe
' >        Rewri*gine On
' >        RewriteRule www.collegeskin.apostrophe - [R]
' > </virtualHost>
' >
' >
'
' --
' Bill Moseley

--
David Steuber   |   Hi!  My name is David Steuber, and I am
NRA Member      |   a hoploholic.
http://www.veryComputer.com/

The problem with AI is that it has a mind of its own
        --- Devon Miller

 
 
 

httpd.conf: redirect from one host to another?

Post by David Steube » Thu, 10 Aug 2000 04:00:00


' Why not just redirect the page with javascript instead of messing with
' the conf file?
' Try this.
'
' <SCRIPT LANGUAGE="JavaScript">
' <!-- Begin
' window.location="http://www.your-web-site-address-here.com/javascript-pa
' ge.html";
' // End -->
' </script>

Because I don't want to rely on the client having JavaScript enabled.
I want the server to send a 302 with Location: header.

I also don't want to set up a directory for the domain that gets
redirected.

--
David Steuber   |   Hi!  My name is David Steuber, and I am
NRA Member      |   a hoploholic.
http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=hoplite&subm...

The problem with AI is that it has a mind of its own
        --- Devon Miller

 
 
 

httpd.conf: redirect from one host to another?

Post by Miguel Cr » Thu, 10 Aug 2000 04:00:00



> Why not just redirect the page with javascript instead of messing with
> the conf file?

The only reason someone would want to use a redirect to the same server
rather than just ServerAlias, is because they want search engines and such
things to pick up on it and correct the address in their indices. Since
all of those systems are smart enough to ignore JavaScript, the enterprise
would end up being pointless.

miguel

 
 
 

httpd.conf: redirect from one host to another?

Post by Bill Mosele » Thu, 10 Aug 2000 04:00:00



steuber.com) remarked...

Quote:> ' You didn't post your NaveVirtualHost directive.

> I don't know that directive.  I have this directive:

> NameVirtualHost 10.7.7.11

Heehee.  That's what I get for not having all the Apache directives in
my spelling module.

Quote:> ' You also have a ServerAlias for the second that matches the first.  You
> ' can't have two different name-based servers with the same name, of
> ' course.

> I'm aware.  Perhaps you can elucidate on ServerALias.  I thought I was
> following the example in ``Professional Apache'' correctly.
> Apparantly not.

My guess is you have this all figured out now, but I'm here:

Ok, basically

Quote:> NameVirtualHost 10.7.7.11

says any connection on that IP are assumed to be name-based virtual
host.  Then to determine which <VirtualHost 10.7.7.11> section to use,
Apache looks at the Host: header and matches against any ServerName or
ServerAlias directives.  Therefore, it doesn't make sense to have two
name-based virtual hosts that could match a given Host: header.

--
Bill Moseley

 
 
 

httpd.conf: redirect from one host to another?

Post by David Steube » Sat, 12 Aug 2000 04:00:00


' Ok, basically
' > NameVirtualHost 10.7.7.11
' says any connection on that IP are assumed to be name-based virtual
' host.  Then to determine which <VirtualHost 10.7.7.11> section to use,
' Apache looks at the Host: header and matches against any ServerName or
' ServerAlias directives.  Therefore, it doesn't make sense to have two
' name-based virtual hosts that could match a given Host: header.

I didn't think I was doing that, but I could have gotten backwards
things dyslexic I am. ;-)

Certainly that makes sense.  And when the Host header is absent, my
site won't work at all.  However, the user will get to see Apache
online documentation ;-).

--
David Steuber   |   Hi!  My name is David Steuber, and I am
NRA Member      |   a hoploholic.
http://www.m-w.com/cgi-bin/dictionary?book=Dictionary&va=hoplite&subm...

The problem with AI is that it has a mind of its own
        --- Devon Miller

 
 
 

1. Test httpd.conf setup - using variables in httpd.conf

I'm often testing Apache httpd.conf setups using a parallel
DocumentRoots.  I'd like to be able to use variables in httpd.conf file,
such that:

   $dir = 'test_dir';

   DocumentRoot /usr/local/web/$dir
   <Directory /urs/local/web/$dir/some_dir>

And when ready to use on live data just change:

   $dir = 'live_data';

or some such thing.

Any tricks for doing this?

--

pls note the one line sig, not counting this one.

2. problem with tar -- "padding with zeros" error

3. Can I define srm.conf, access.conf in httpd.conf ?

4. Forte for Java 3.0 CE on FreeBSD 4.3

5. Maximum Redirects in apache httpd.conf

6. Possible bug

7. httpd.conf: ServerAlias changes URL in Browser (redirect instead of alias)

8. Shared libraries

9. Redirect (in httpd.conf) no longer works

10. Trying to redirect a URL with a variable - in httpd.conf

11. Vitual host httpd.conf

12. httpd.conf => any way to reference Virtual Host Section to external file?

13. httpd.conf and virtual hosts, mod_ssl - Need Help plz