9
votes

I have some forums installed on my site at http://ironnoob.com/forums.

My website lives in c:\IronNoob and my forums are installed in c:\IronNoob\forums

I want both "ironnoob.com" and "www.ironnoob.com" to do a server-side redirect to "ironnoob.com\forums".

I'm using IIS 7 and I'm new to setting up this stuff so I don't even know what to google for. I know I can do a client-side redirect with HTML, but I understand that the server-side redirect is nicer. I've figured out how to install the HttpRedirect module for IIS, but if I set up a redirect in the root folder of my site to my forums folder, I get a circular redirect error when visiting ironnoob.com.

HTTP Redirect Settings:

  1. root directory selected in Connections pane of ISS
  2. Check "Redirect requests to this destination"
  3. destination = http://somesite.com/forums
  4. Check "redirect all requests to the exact location"
  5. Check "only redirect requests to content in this directory (not subdirectories)"
  6. Status code: Permanent (301)

Why is it redirecting subdirectories when I told it not to? What is the right way to do this?

1
I guess you should google 301 redirect IIS. This is IIS 6 but this works the same way with IIS 7: stackoverflow.com/a/888356/1443490cheesemacfly
The thing I'm most afraid of is setting up a circular reference - if somesite.com -> somesite.com/forums -> somesite.com/forums/forums -> etcJohn Shedletsky
How is your IIS currently setup?cheesemacfly
Ok, my mental model of the program was wrong. There's not a pile of global redirects, there's one for each node you're in in the site explorer pane. Got it working. Thanks.John Shedletsky
Actually I was wrong again. I was getting a million nested redirects. Why is this so hard in IIS.John Shedletsky

1 Answers

25
votes

Instead of using the HTTP redirect module, you can use the URL rewrite one.

Run the inetmgr command and select your website root. Open the URL rewrite configuration:

URL rewrite configuration

Click on Add a rule on the right panel. Select a Blank rule in inbound rules:

Blank rule

From here you have to name your rule and select the Does not match the pattern option. You then have to set the Pattern (in this case, it means that a URL not starting with forums will trigger this rule):

Rule conditions

The last step is to set up your redirect. You probably want to go with a 301 redirect as advised by Google:

Redirect rule

Click Apply on the right panel and you should be good to go.

NOTE: If your Redirect URL doesn't match your Pattern you will be stuck in an infinite loop (you can test it by simply clicking the Test button will writing your Pattern).

Documentation for this module available here