Forum Moderators: open

Message Too Old, No Replies

IIS Redirect - All without www to with www

Redirecting x.com to www.x.com

         

moopy

8:30 am on Jun 18, 2007 (gmt 0)

10+ Year Member



Hello there,

I was wondering what's the easiest way to configure IIS to permenantly redirect all urls without the www to all the urls with www

for example:

redirect x.com to www.x.com
And x.com/1.html to www.x.com/1.html etc.

Thanks!

Moopy.

makeupalley

7:11 am on Jun 19, 2007 (gmt 0)

10+ Year Member



Hi there moopy,

You can use server variables to see what the domain is and redirect if it has no www, for example

If Left(Request.ServerVariables("HTTP_HOST"),3)<>"www" Then

strRedirect = "www." & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")
Response.Clear()
Response.Redirect(strRedirect)

End If

Hope this helps

moopy

8:34 am on Jun 25, 2007 (gmt 0)

10+ Year Member



It does, thanks.

I was lso wondering if there's a way to redirect it through the IIS, without touching the code?

Thanks.

dukelips

5:26 pm on Jun 26, 2007 (gmt 0)

10+ Year Member



configure IIS like that

mattur

6:12 pm on Jun 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To expand further on dukelips gnomic post ;), yes you can configure IIS to do this at the site level. You set up the non-www site as normal then configure it to redirect as described in this post [webmasterworld.com].