Welcome to WebmasterWorld Guest from 54.166.33.25

Forum Moderators: ocean10000

Help with 301 Redirection in IIS

   
7:24 am on Mar 4, 2008 (gmt 0)

5+ Year Member



Hello,

I have set up a 301 permanent redirect in my IIS which will redirect requests for domain.com to www.domain.com

This is working fine, but whenever there is a request for URLs such as

domain.com/file.aspx
domain.com/contac.aspx

..these are also getting redirected to www.domain.com

How do I fix this...I want requests for domain.com/contact.aspx to redirect to www.domain.com/contact.aspx

Another thing that I want to know is how do I redirect the index file to /

Whenever I try to redirect is through the IIS control panel by right-clicking>properties>redirect it is creating an infinite loop.

Thanks a lot in advance!

6:27 pm on Mar 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can redirect a specific file by right clicking the file in IIS, click "properties" and then select the radio button "A redirection to a URL. This will allow you to redirect individual pages. If contact.aspx doesn't exist in the directory anymore, just create a file named contact.aspx with notepad and then setup your redirect. Be sure to check the box that says "a permanent redirection..."

Whenever I try to redirect is through the IIS control panel by right-clicking>properties>redirect it is creating an infinite loop.

Not sure what you mean by this... Could you elaborate please?
6:36 pm on Mar 5, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See this thread: Domain level 301 redirect clips the query strings [webmasterworld.com] (it describes redirecting urls and query strings at the site level). HTH.
1:31 am on Mar 6, 2008 (gmt 0)

10+ Year Member



Another option for you that I use to solve the cononical URL issue. Place this in the Global.asax Application_BeginRequest Sub.

If Request.ServerVariables("HTTP_HOST") = "mydomain.com" Then
Response.Status = "301 Moved Permanently"
Response.AddHeader("Location", "http://www.mydomain.com" & Request.RawUrl)
End If

6:35 am on Mar 6, 2008 (gmt 0)

5+ Year Member



Thanks friends for your replies,

I have fixed the first problem, now let me share with you all how I did it:

I created a site in the IIS with domain.com as the host name and then 301 redirected it [by right click > properties] to www.domain.com$S I was missing the $S part for which requests for domain.com/contact.aspx was getting redirected to www.domain.com. The redirect wasn't passing any suffixes. So I fixed that and it's working fine. Thanks again!

Now the BIG problem (for me at least)

How do I redirect www.domain.com/default.aspx to www.domain.com/

I have tried numerous ways of doing this, but it just doesn't work. I would be very grateful if you all can guide me through this.

Thanks a lot in advance :-)

8:30 pm on Mar 9, 2008 (gmt 0)

10+ Year Member



Pretty sure you need to add $Q in order to preserve the querystring on the redirect target. So for example in the "Redirect to" field you need: [domain.com$S$Q...]

To redirect "/default.aspx" to "/" I think you have to use IsapiRewrite or similar.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month