Поделиться через


“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.

snap006 

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 https://www.iis.net/extensions/URLRewrite, installed it, and started to configure the redirect.

snap007

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!

snap005

 

 

 

Now, clear browser cache and revisit the site:

snap004

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.

Comments

  • Anonymous
    January 14, 2010
    I used to have the issues with 302 redirect. My developers didn't take it serious and the result was my site's snippet terribly changed in Google SERPs.

  • Anonymous
    March 21, 2011
    Hi Jie Li, thanks for the great information.  I have the same problem but with IIS 6 and sharepoint.  How can this be solved.  My programmer has tried to solve it but it effectively creates an endless loop. SharePoint temporarily redirects to the default page and the default page is permanently redirected back to the root by IIS.  How can this be solved, thanks in advanced

  • Anonymous
    May 19, 2011
    Re: II6 and SharePoint There is an ISAPI module developed by Helicon that works well.

  • Anonymous
    August 12, 2011
    Hi Jie Li, This is great solution if you can know all your welcome pages are named "default.aspx" Do you know if there is a rule using URL rewrite or other solution that would be smart enough to redirect you to the welcome page instead of just default.aspx? Thanks! Tonny

  • Anonymous
    August 03, 2015
    Hi, I thought of this.. but my url redirect url list is long. approx. 650 url to be redirected. No similarity in URLs also. all different. So, if I follow this, I will end up writing a long list of rules.    does it worth it.. or should I go with custom redirect http module. I tried with custom one.. pretty straight forward for me, but it always give 302 instead of 301.. any idea.