...

View Full Version : domain.com REDIRECTS TO www.



Morgoth
03-20-2003, 12:46 AM
Hello...

Now, I am not on Windows 2000 Server and I am unable to create more then one website with host headers. (IIS 5.0)

Now, my problem is, if a person types in http://domain.com I want it to redirect it to http://www.domain.com

Example sites:
http://google.com REDIRECTS TO www.
http://yahoo.com REDIRECTS TO www.
http://real.com REDIRECTS TO www.
Plus many others which I am sure you can find, now.

Now I don't know exactly how this done, and I have 2 methods that seem like the only way I know...

One is to set up a include page that is included on all of my pages (already have one for config reasons; Easier to edit my site and such) and have it check my site's "Server_Name" or "Http_Host" with ASP and requesting the server variable (ASP). It will check to see if www.domain is there, if not then it will redricted it to www.domain & What ever the rest of the info is. Either just .net or .net/page.asp.

The other is to set up a virtual site with Windows 2000 Server that uses host headers and if typed in domain.com it will send it to www.domain.com with the idea of number one.


Does anyone have a clue what I am talking about, and/or will be able to help me find the real method or what not?

krycek
03-20-2003, 01:39 AM
Why redirect...?

Just DON'T redirect.

The default action *should* be that, if you don't redirect, "all roads lead to Rome" lol, i.e. everything goes to the same place.

At least, that's what BIND does on a *nix box.

::] krycek [::

Morgoth
03-20-2003, 01:46 AM
It's not a redirect that I want...

I am just trying to find a way to do this exactly, so redirecting is not the way I really want to do it...

This is possible a full Web server issue and has nothing to do with my DNS, but I am not sure about that, anyone know if I can do this with my DNS?

I am at a full loss for this issue except for my two method above...

oracleguy
03-20-2003, 01:51 AM
Its tough without running server.

Try opening the HOSTS file under \winnt\system32\drivers\etc

Then enter in:

<your IP Address> www.domain.com

There should be some comments in it about how to use the file and such. Give that a try.

It might not work unless thats in the computer the persons viewing from... I forget its been awhile... If that doesn't work you'll need to configure it through your DNS server.

krycek
03-20-2003, 02:00 AM
that's not what hosts is for...

I don't know how to do it in windows, only linux, but you may learn something from this, I don't know:

http://www.tldp.org/HOWTO/DNS-HOWTO.html#toc7

Yup it's for BIND but hey, the theory is that same :)

::] krycek [::

Morgoth
03-20-2003, 02:04 AM
It's odd how you know so much oracleguy... ;)

I will look at this.. But hum.. I don't get it.

This will allow people to do what exactly?
Please explain more.

Morgoth
03-20-2003, 02:10 AM
Originally posted by krycek
that's not what hosts is for...

I don't know how to do it in windows, only linux, but you may learn something from this, I don't know:

http://www.tldp.org/HOWTO/DNS-HOWTO.html#toc7

Yup it's for BIND but hey, the theory is that same :)

::] krycek [::

I don't get it..
What is this?

krycek
03-20-2003, 02:31 AM
Ok, first about hosts. hosts is simply a file that tells which IPs to look at when you type in a URL. For instance, if you are changing DNS then you might want to force redirect to the new IP using the hosts file. It only applies to your own PC.

Second, the link I gave explains how DNS works. It's where I learn most of what I know about DNS. It's aimed at BIND but there should be something you can learn from it - surely Windows DNS can't be too different...? Until someone who has experience of DNS on Windows can help you, it's the best you've got...

Thirdly, remember, "Google is your friend!" :D

::] krycek [::

Morgoth
03-20-2003, 02:53 AM
Well, I am not running my own DNS, I just use one... So I don't need to know any more about DNS then I should know for using one with text boxes and a submit button.

krycek
03-20-2003, 02:59 AM
ah. In that case, how do you expect us to help you??? :confused: ask whoever manages your DNS! :p

::] krycek [::

Morgoth
03-20-2003, 03:25 AM
Well, I first off, I think it's more of a webserver problem..
So... I figured I would ask about it here...

krycek
03-20-2003, 03:40 AM
well, you should be able to do redirects however I don't see the point when it should be set up in your DNS.

But, simply create a webpage that will immediately refresh to the desired location. Simple?

::] krycek [::

oracleguy
03-20-2003, 03:53 AM
Originally posted by Morgoth
Well, I first off, I think it's more of a webserver problem..
So... I figured I would ask about it here...

No its a DNS problem. And krycek, yeah I was unsure I thought HOSTS only applied to the local computer but was not sure.

Doesn't InterNic handle the DNS stuff as far as aren't they like the internet's DNS server basically? They translate domain.com into an IP address, right?

Since you say you don't have your own DNS server, I'd call up ask the people that are doing your DNS like krycek suggested. Because as you probably know, "www" is a host header and it needs to be registered in the DNS.

Morgoth
03-20-2003, 04:19 AM
www is set as a CNAME towards my A recond of domain.com

So I need to some how direct domain.com to automatically change to www.domain.com

I don't know any other way then the two ways I suggested above.

Does anyone know other methods?

krycek
03-20-2003, 05:16 AM
Morgoth, I'm still not sure what you want to do! The way you describe, they should both go to the same place???

::] krycek [::

Morgoth
03-20-2003, 07:09 AM
They do go to the same place.

My problem wasn't really explained, I didn't think I needed to, but here it goes.

When I write a cookie when someone goes to my site at http://domain.com it stores the cookie as "(ComputerName)@domain.txt".
And when someone goes to my site at http://www.domain.com it stores the cookie as "(ComputerName)@www.domain.txt".

Now that means there are two different cookies with the same information. I don't like that, so I want to make sure everyone views the site and I can read and write the cookies under one file name.

Understand?

Dnyt
03-20-2003, 07:25 AM
If your site can run PHP, so make an index.php file and in that file put.

<?php
header("Location: http://www.domain.com");
?>

Even though, the user type http://domain.com or http://www.domain.dom, it will jumb to http://www.domain.com

krycek
03-20-2003, 07:50 AM
Morgoth - yup, I understand :)

I kinda got confused along the way, but if you look back you will see that I suggested a simple page redirection. However, that would require you to have the two areas separate, so Dnyt's solution is more appropriate.

A word of warning, though: check the current location first! Otherwise, I believe you may redirect at times you do not want to (depending on how you make your site). A simple way to do this is to check if the current URL contains "http://domain.com" and if so, redirect :)

::] krycek [::

Morgoth
03-20-2003, 02:21 PM
Originally posted by krycek
A word of warning, though

Originally posted by Morgoth
One is to set up a include page that is included on all of my pages (already have one for config reasons; Easier to edit my site and such) and have it check my site's "Server_Name" or "Http_Host" with ASP and requesting the server variable (ASP). It will check to see if www.domain is there, if not then it will redricted it to www.domain & What ever the rest of the info is. Either just .net or .net/page.asp.

That's the idea I had in the first place, I will look into if PHP would have any other solutions as well.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum