How to redirect URLs to the correct website

Hello,

I was wondering how URL redirection is handled.

Say for instance I type in google.com into my webrowser. How is it automatically redirected to www.google.com

Thanks!
LVL 1
Methodman85Asked:
Who is Participating?
 
Springy555Commented:
To get this working you need to do the following:

Ensure you have a DNS record setup named WWW.  This needs to point to the same IP address as website.com.  A test to see if this has been done is to ping www.website.com.  It should at least resolve to an IP address.  Whoever manages your DNS should be able to create this record for you.

Next, in IIS you need to have 2 websites.  One website for website.com, which will have a host header of website.com only.  A second website for www.website.com.  This website will hold all your web content.  You must make sure it has a host header of www.website.com only.  You can modify/add the host header by right clicking on your website in IIS manager console, selecting properties.  Click the advanced button on the website tab, and its there you can add the host headers.

Now you need to setup the redirect for the website.com website.  This can be done numerous ways, but the quickest is:

- Right click website.com, select the home directory tab.  Select 'A redirection to another URL', and type in www.website.com

What will happen is that someone will type website.com in their browser.  The request will hit your webserver.  It will match the host header for website.com website.  It will see the redirect you set up to www.website.com.  It will send that back to the users browser, which will then try and load www.website.com.  Again this will match the host header for www.website.com and load that website.  Th URL in the users browser would also have changed from website.com to www.website.com.

But remember for this to work, you need to have a WWW DNS 'A' record setup, pointing to the same IP as website.com.  Or a DNS CNAME record for WWW, resolving to website.com.
0
 
James MurrellProduct SpecialistCommented:
simple explation can be found at http://www.webconfs.com/how-to-redirect-a-webpage.php with examples for iis
0
 
Methodman85Author Commented:
So are you saying that if I right click on my websites index.html file, select A redirection to a URL, and under local path type www.website.com
it would redirect to the www site?
0
How do you know if your security is working?

Protecting your business doesn’t have to mean sifting through endless alerts and notifications. With WatchGuard Total Security Suite, you can feel confident that your business is secure, meaning you can get back to the things that have been sitting on your to-do list.

 
James MurrellProduct SpecialistCommented:
Yes IIS Redirect In internet services manager, right click on the file or folder you wish to redirect Select the radio titled "a redirection to a URL". Enter the redirection page Check "The exact url entered above" and the "A permanent redirection for this resource" Click on 'Apply'
 
as always test in non production machines if unsure

 
0
 
Methodman85Author Commented:
It didn't work. I just want the www name to show in the url bar after the user types website.com without the www infront of it.
When I did this redirection website.com went to a Bing search.
and www.website.com didn't even load.
These aren't seperate sites, I'm not trying to redirect to another site, it's the same site, I just want the www infront.
Did I do something wrong, am I suppose to redirect the index.html file, or the entire website?
0
 
James MurrellProduct SpecialistCommented:
who is your domain name with?
0
 
ahoffmannCommented:
> How is it automatically redirected to ..
either the server sends a 30x redirect status with the new location
or the browser cannot resolve the given DNS name and autocompletes it (see yur browser properties)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.