SharePointバニティURL /リダイレクトのベストプラクティス
-
05-07-2019 - |
質問
私の雇用主は、会社のイントラネットにMOSS 2007を使用しています。安全なhttp上でのみ実行され、ISAを介して外部に公開されます。現在、次のようなものが発生するように、転送URLをサイトに追加するリクエストがあります。
intranet.mycompany.com/vanityname
->へのリダイレクト
intranet.mycompany.com/somedeeplink/default.aspx
時間が経つにつれて、この種のことがユーザーに人気を集めることを完全に期待しています。そのため、拡張可能なソリューションを探しています。転送メタタグまたは転送SharePointページタイプを使用した/ site /の作成に関するさまざまな記事を読みました。また、IISに仮想ディレクトリなどを直接追加することについて話している人もいます。これらのソリューションはすべて過剰であるように思われ、必然的にWebサーバーでより多くのメモリまたは処理時間を消費します。
現在、web.configで構成してリダイレクトを実行できるhttpモジュールの作成に傾倒しています。他の誰かがSharePoint 2007で似たようなことをして、提案があったかどうかを確認するためにフィードバックを得たいと思いました。繰り返しますが、後で大きな変更を加えることなくスケーリングし、Webサーバーの処理負荷を最小限に抑えるものを実装したいと思います。ありがとう!
解決
HTTPモジュールルートを使用してMOSSでURLリダイレクトを実装しました。ここで、使用したコードと、どのパラメーターが最適であったかを文書化しました。
http://scaredpanda.com / 2008/08 / url-rewriting-with-sharepoint-moss-2007 /
見てみて、これがあなたに役立つかどうか、そして何か質問があれば教えてください。
更新:上記のリンクは無効になったため、ここでURLリダイレクトに使用したページのテキストを入力してください。
少しいじってから、良い方法を思いつきました。私がウェブで例を探していたとき、それができなかったと言っている多くの人々がいました。しかし、最終的には実際にそれを実装するのに多くの時間はかかりませんでした。これが作業を行うために書いたHttpModuleです。
重要な部分は、this.app.BeginRequest + = new EventHandler(app_BeginRequest)which リクエストの前にステップし、モジュールがリダイレクトを取得できるようにします。
そしてHttpContext.Current.RewritePath(redirect、false);受信する.aspxページが正しくポストバックする方法を理解できるように、必要なヘッダーnをそのような前方にプッシュします。
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
&& url != "/"
&& !url.EndsWith("/pages")
&& !url.Contains(".aspx")
&& 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
}
}
}
}
他のヒント
代替アクセスマッピングを確認しましたか
ソリューションへの支払いを受け入れる場合。ご覧ください:
無料ではありません-> http://www.muhimbi.com/Products/SharePoint-URL-Shortener。 aspx
リダイレクトの数によっては、前述のようにHTTPモジュールを実装することもできますが、チェックアウトはどうですか
IISのURL書き換え機能を使用します。 (IIS 7拡張機能だと思います)