Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ive implemented url redirecting with MOSS using the HTTP module route. I documented the code I used and what parameters worked the best for me here;</p> <p><strike><a href="http://scaredpanda.com/2008/08/url-rewriting-with-sharepoint-moss-2007/" rel="nofollow noreferrer">http://scaredpanda.com/2008/08/url-rewriting-with-sharepoint-moss-2007/</a></strike></p> <p>Take a look and let me know if this helps you and if you have any questions.</p> <p><strong>Update:</strong> The link above is no longer valid, so here text from the page that I used for URL redirect.</p> <p>After messing around for a little bit it, I came up with a good way to do it. When I was looking for examples on the web there were a lot of people saying that it couldnt be done. But in the end it actually didn’t take much to implement it. Here’s an HttpModule that I wrote to do the work.</p> <p>The key pieces are the this.app.BeginRequest += new EventHandler(app_BeginRequest) which steps in front of the request and allows the module to get its redirect on.</p> <p>And HttpContext.Current.RewritePath(redirect, false); will push the necessary headers n such forward so that the receiving .aspx page will understand how to correctly post back.</p> <pre><code>using System; using System.Data; using System.Data.SqlClient; using System.Reflection; using System.Collections; using System.Text; using System.Web; using System.Web.Caching; using System.Web.SessionState; using System.Security.Cryptography; using System.Configuration; using System.Threading; using System.IO; using System.Security; using System.Security.Principal; namespace ScaredPanda { public sealed class RewriteHttpModule : IHttpModule { HttpApplication app = null; /// /// Initializes the httpmodule /// public void Init(HttpApplication httpapp) { this.app = httpapp; this.app.BeginRequest += new EventHandler(app_BeginRequest); } public void app_BeginRequest(Object s, EventArgs e) { try { //determine if the income request is a url that we wish to rewrite. //in this case we are looking for an extension-less request string url = HttpContext.Current.Request.RawUrl.Trim(); if (url != string.Empty &amp;&amp; url != "/" &amp;&amp; !url.EndsWith("/pages") &amp;&amp; !url.Contains(".aspx") &amp;&amp; url.IndexOf("/", 1) == -1) { //this will build out the the new url that the user is redirected //to ie pandas.aspx?pandaID=123 string redirect = ReturnRedirectUrl(url.Replace("/", "")); //if you do a HttpContext.Current.RewritePath without the 'false' parameter, //the receiving sharepoint page will not handle post backs correctly //this is extremely useful in situations where users/admins will be doing a //'site actions' event HttpContext.Current.RewritePath(redirect, false); } } catch (Exception ex) { //rubbish } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload