hostname redirect

hostname redirect

Post by Marc Tardi » Thu, 12 Oct 2000 04:00:00



How do webservers redirect one hostname to another? For
example, when connecting to "google.com" the server somehow
redirects the user to "www.google.com".

I thought only adding "Location: http://www.google.com" to
the header could do the redirect, but there is no trace of
the "Location" parameter in the google HEAD. I then
discovered the 301 Permanent Redirect message, which would
make sense, but when connecting to port 80 of google.com
using telnet, there is no mention of "301" in the HEAD. So
what does the server do to redirect the user to a specific
hostname?

 
 
 

hostname redirect

Post by Joshua Sliv » Thu, 12 Oct 2000 04:00:00



> How do webservers redirect one hostname to another? For
> example, when connecting to "google.com" the server somehow
> redirects the user to "www.google.com".
> I thought only adding "Location: http://www.google.com" to
> the header could do the redirect, but there is no trace of
> the "Location" parameter in the google HEAD. I then
> discovered the 301 Permanent Redirect message, which would
> make sense, but when connecting to port 80 of google.com
> using telnet, there is no mention of "301" in the HEAD. So
> what does the server do to redirect the user to a specific
> hostname?

HTTP/1.0 302 Moved Temporarily
Date: Wed, 11 Oct 2000 21:27:47 GMT
Server: GWS/1.9
Connection: close
Location: http://www.google.com/
Cache-Control: No-Cache
Content-Length: 162
Content-Type: text/html

The 302 status code combined with the Location header do the trick.

--
Joshua Slive

http://finance.commerce.ubc.ca/~slive/

 
 
 

hostname redirect

Post by Marc Tardi » Thu, 12 Oct 2000 04:00:00


[ snip ]
Quote:> HTTP/1.0 302 Moved Temporarily
> Date: Wed, 11 Oct 2000 21:27:47 GMT
> Server: GWS/1.9
> Connection: close
> Location: http://www.google.com/
> Cache-Control: No-Cache
> Content-Length: 162
> Content-Type: text/html

Right, after "HEAD / HTTP/1.1" I forgot to add "Host: google.com"
which is clearly required as specified in the HTTP/1.1 standard.
Of course, GWS is cheating in the above example, since "Host:" is
not necessary according to the HTTP/1.0 standard. If omitted,
GWS returns a "200 OK" response for both versions of the protocol.
I guess the server still needs a bit of work...
 
 
 

1. Better way to do Apache hostname redirects than this?

I work for a company that has over 350 stores. Each store will have
its own URL:

<storenumber>.<mycompany>.com that redirects to a specific URL on our
main web site.

What I am planning to do right now is to add over 350 VirtualHost
entries to the Apache httpd.conf file like this:

<VirtualHost *>      
ServerName 111.mycompany.com
Redirect / http://www.mycompany.com/store.jsp?store=111
</VirtualHost>

<VirtualHost *>      
ServerName 222.mycompany.com
Redirect / http://www.mycompany.com/store.jsp?store=222
</VirtualHost>

Is this the most efficient method to do this? Can I use Rewrites?
Since the hostname and redirect URL follow the same pattern, I am
hoping I can do something more dynamic than to manually add an entry
for each store we have - since store numbers do change from time to
time. I thought I read that rewriting might help me with this problem.

Ideas, please! I am no expert. Thank you in advance!

2. finding...

3. redirecting to different hostname and dropping query string

4. lex bug ...

5. Redirects based on remote hostname?

6. x-problem

7. Forbid or redirect depending on hostname

8. How to set up NFS

9. howto? hostname.domain redirect to http://someplace.blabla

10. how to redirect on hostname?

11. redirect hostname alias, netscape?

12. Want NCSA HTTPd to redirect based on hostname..

13. Internal port redirecting based on hostname