Redirecting to the same webspace but different domain

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I have a website which amongst other things has a message forum which
uses cookies to allow users to login.  I am in the process of changing
the domain of the site and ideally want the old address to automatically
redirect to the new one so that cookies will be created and read for the
new site address.  The problem with using meta HTTP-EQUIV="REFRESH"
would be that once it's redirected I don't want it to keep redirecting
as effectively the redirect is to the same same webspace but with a
different domain.  Is there a way I can do this?  I suppose I could
create an INDEX.HTM file and redirect to that as opposed to the current
INDEX.HTML file which I think would take precedence but I'd rather find
a better way of doing it.  Would appreciate any help.


Re: Redirecting to the same webspace but different domain

This cannot be done with static HTML, since the HTML itself cannot know
what the HTTP Host header says.  You'll need a bit of server-side
programming to make it happen.

-- Easily organize and disseminate news and
                              photos for your family or group.

Re: Redirecting to the same webspace but different domain

Lisa wrote:

Quoted text here. Click to load it

This isn't something that can be sensibly handled with HTML.

On the old domain:

1. Generate a one time only authorisation token.
2. Store the cookie data on the server with the token.
3. Send a 301 Redirect HTTP response to the user along with a location
header that redirects them to a server side on the new site. Include, in
the query string of that URL, the auth token and the page they were trying
to visit.

On the new domain (in the aforementioned server side script):

1. Use the auth token to look up their credentials in the database
2. Send a 302 redirect response which includes headers to set their cookies
and redirect them to the page they were trying to get to in the first place
(although on the new domain)
3. Delete the auth details from the database

(This does assume that when you say "changing the domain" you don't mean
"changing the domain and server". Coping with transmitting the
authentication details to the new server as well will make things a little
more complicated).

David Dorward       < <
                     Home is where the ~/.bashrc is

Site Timeline