“Fix” SharePoint 302 redirect problem by IIS7 and URL Rewrite
Recently in my spare time I’m helping my friends to get their internet facing sharepoint site up and running. Since this is for the internet, the first thing they need to consider is SEO. So we have a well known problem now: SharePoint use 302 temp redirect instead of 301. If you do a search for “sharepoint 302” you will see a lot of articles talking about the problem.
Here’s the default SharePoint Site. The request was temporarily redirected (302) to Pages/default.aspx. Search engine bots don’t like it, they like 301. So this is BAD.
How to solve it? Oh, I’m a IT Pro person, I don’t want to deal with a custom redirect HttpModule – god knows what will happen if those custom code mess up my sites! So any other options?
I’m lucky because I installed SharePoint on Windows Server 2008, so I can use IIS7 features. I downloaded URL Rewrite module from http://www.iis.net/extensions/URLRewrite, installed it, and started to configure the redirect.
Choose your site in IIS Manager, click URL Rewrite, and create a new blank rule.
Use Regular Expressions to match ^$ (which means “empty”). Set Action Type to Redirect, and add the redirect URL (by default should be Pages/default.aspx), set redirect type to Permanent (301). You are all set!
Now, clear browser cache and revisit the site:
It is 301 now! Pretty easy, isn’t it?
URL Rewrite module is great. If you are a regex guru you can also create more complex rules to make everything fit for your site.