Welcome to WebmasterWorld Guest from 54.209.227.199

Forum Moderators: ocean10000

Message Too Old, No Replies

non-www to www redirection on IIS

     
8:31 am on Sep 16, 2011 (gmt 0)

New User

10+ Year Member

joined:July 9, 2007
posts: 31
votes: 0


Hi Guys,

I have having some problems redirecting non-www to www on an IIS webserver.

The website is on a shared server and i have contacted my web hosting company but they have said that they are not willing to configure it.

They have said that I can use an ASP redirect script to do this but how can I use ASP when I am trying to redirect mydomain.com to www.mydomain.com.

The only way is through IIS right?

Thanks in advance.

Cy.
8:36 am on Sept 16, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


You can do it in ASP.

Detect if requested URL does not begin www.example.com and use response.header (or whatever it is called) to send a redirect back out.

You can also do it in the server configuration. Method varies depending on which version of IIS you use.

There are several previous threads with the code for every method.
8:41 am on Sept 16, 2011 (gmt 0)

New User

10+ Year Member

joined:July 9, 2007
posts: 31
votes: 0


Thanks for the reply.

Where do i place the ASP code? On the index.html file or create a new file? Please can you show me an example of the code if possible.

Thanks again.
10:21 am on Sept 16, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


You place the ASP code at the very top of every page that might be requested with the wrong domain name.

As for code, use the forum search to find hundreds of previous examples.
11:41 am on Sept 16, 2011 (gmt 0)

New User

10+ Year Member

joined:July 9, 2007
posts: 31
votes: 0


Thanks but how can i put a redirect ASP code on a non-www (example.com)?
11:53 am on Sept 16, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


You put the code on page6 and the code says "if the requested URL was example.com/page6 then redirect to www.example.com/page6".

If the requested URL was example.com/page6 then obviously the redirect code doesn't run and instead the real page6 content is served.
12:11 pm on Sept 16, 2011 (gmt 0)

New User

10+ Year Member

joined:July 9, 2007
posts: 31
votes: 0


At the moment whats happening is if you type in example.com then that page is served and then if you type in www.example.com then that page is served which is the same as example.com and which is duplicate content right?

How can i redirect example.com to www.example.com?

Thanks again and sorry to be a pain
12:15 pm on Sept 16, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


I thought I already explained it. Which bit didn't you understand?
12:36 pm on Sept 16, 2011 (gmt 0)

New User

10+ Year Member

joined:July 9, 2007
posts: 31
votes: 0


What i am trying to say is that how can i put a ASP redirect code on example.com so it would redirect to www.example.com, as i am using an index.html file for my home page?

Sorry to be so confusing...
8:10 am on Sept 17, 2011 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15636
votes: 795


Holy ###. g1, are you saying he'd have to put in this bit of code at the top of each and every individual page? Or should I not be trying to understand this stuff at 1AM?
8:36 am on Sept 17, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


Yes, if you want to do this in ASP it needs to be at the top of the page.

Of course, in a fully dynamic site this would mean adding once it to just one file.
3:26 pm on Sept 17, 2011 (gmt 0)

Administrator

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month

joined:Jan 14, 2004
posts:864
votes: 3


There is another way depending on the version of IIS you are running.

If you are using IIS 7 or later this add-on will work for the whole site. It is configurable via the IIS management tool once installed.
[iis.net...]
6:31 pm on Oct 5, 2011 (gmt 0)

New User

10+ Year Member

joined:Aug 12, 2006
posts:17
votes: 0


Hey guys, I've never worked with ASP before and am trying to configure a redirect using Server.Transfer instead of the individual page redirect. If anyone can help me redirect my /index.asp page to the root using a Server.Transfer method, that would be greatly appreciated.
Below is the code I've found if you want to use Response.Redirect on an individual page level. I haven't used it, so I can't troubleshoot or assist in implementation.
<%@ Language=VBScript %>
<%
' Permanent redirection
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.example.com/"
Response.End
%>
4:15 am on Oct 6, 2011 (gmt 0)

Administrator

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month

joined:Jan 14, 2004
posts:864
votes: 3


What is your goal in using Server.Transfer instead of the Response redirect?

Server.Transfer will not change the displayed URL in the browser.

Reference:
Server.Transfer Method [msdn.microsoft.com]
9:13 am on Feb 3, 2012 (gmt 0)

Preferred Member

10+ Year Member

joined:Mar 30, 2006
posts: 399
votes: 0


can it be done by create two sites in iis. moving non www sites to www
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members