Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

When user goes to http://site/web/ I do not want them to be redirected to that web's welcome page, http://site/web/pages/default.aspx.

How can I disable this redirection?

I am fully aware this would result in a 404 error which is what I want.

share|improve this question
3  
Could you just set the welcome page to a custom error page? –  RJ Cuthbertson Jan 18 '13 at 18:35
    
This would still redirect. I want to disable this redirection altogether. –  iambriansreed Jan 18 '13 at 18:53
    
I know. I don't think you can disable it. I was suggesting an alternative that works with SharePoint rather than against it. –  RJ Cuthbertson Jan 18 '13 at 18:55
    
Added my solution below. Thanks @rjcup3 for the idea. –  iambriansreed Jan 18 '13 at 19:02

2 Answers 2

up vote 1 down vote accepted

Here is what I came up with:

web.AllowUnsafeUpdates = true;
SPFolder rootFolder = web.RootFolder;
rootFolder.WelcomePage = "";
rootFolder.Update();
web.AllowUnsafeUpdates = false;

This works great. Will probably add this snippet to an event receiver when new webs are created.

Note: Setting the Welcome Page to nothing ("") can only be done pragmatically. The /_Layouts/AreaWelcomePage.aspx page won't let you do this.

share|improve this answer

you can also open up SharePoint designer. Create a new page, right click, select "set as home page", then delete the page.

Edit

Be sure to create the page at the root of the site and not in "pages" or you will still get /pages in the URL (although it will still throw a 404).

share|improve this answer
    
Ha. Never tried that in SharePoint designer. –  iambriansreed Jan 18 '13 at 20:39
    
Technically the redirect still happens, but it redirects to a page that doesn't exist, thus throwing a 404. –  Jesus Shelby Jan 18 '13 at 21:08
    
Yes, which is why I can't accept it. My answer below does disable this redirection. –  iambriansreed Jan 18 '13 at 21:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.