Example 6: Migrating Apache Rewrite Module Rules 编辑

Example Inc., is currently using the Apache rewrite module to process search requests sent to its Web servers and redirect those requests to the appropriate server on the basis of information in the request URL. Example Inc. wants to simplify its setup by migrating these rules onto the Citrix ADC platform.

Several Apache rewrite rules that Example currently uses are shown below. These rules redirect search requests to a special results page if they do not have a SiteID string or if they have a SiteID string equal to zero (0), or to the standard results page if these conditions do not apply.

The following are the current Apache rewrite rules:

  • RewriteCond %{REQUEST_FILENAME} ^/search$ [NC]
  • RewriteCond %{QUERY_STRING} !SiteId= [OR]
  • RewriteCond %{QUERY_STRING} SiteId=0
  • RewriteCond %{QUERY_STRING} CallName=DisplayResults [NC]
  • RewriteRule ^.*$ results2.html [P,L]
  • RewriteCond %{REQUEST_FILENAME} ^/search$ [NC]
  • RewriteCond %{QUERY_STRING} CallName=DisplayResults [NC]
  • RewriteRule ^.*$ /results.html [P,L]

To implement these Apache rewrite rules on the Citrix ADC, you would create rewrite actions with the values in the following tables.

Action NameType of Rewrite ActionExpression to choose target referenceString expression for replacement text
Action-Rewrite-Display_Results_NulSiteIDREPLACEHTTP.REQ.URL“/results2.html”
Action-Rewrite-Display_ResultsREPLACEHTTP.REQ.URL“/results2.html”

You would then create rewrite policies with the values as shown in the tables below.

Policy NameAction NameUndefined ActionExpression
Policy-Rewrite-Display_Results_NulSiteIDAction-Rewrite-Display_Results_NulSiteIDNOREWRITEHTTP.REQ.URL.PATH.SET_TEXT_MODE(IGNORECASE).EQ(“/search”) && (!HTTP.REQ.URL.QUERY.CONTAINS(“SiteId=”) || HTTP.REQ.URL.QUERY.CONTAINS(“SiteId=0”) || HTTP.REQ.URL.QUERY.SET_TEXT_MODE(IGNORECASE).CONTAINS(“CallName=DisplayResults”))
Policy-Rewrite-Display_ResultsAction-Rewrite-Display_ResultsNOREWRITEHTTP.REQ.URL.PATH.SET_TEXT_MODE(IGNORECASE).EQ(“/search”) || HTTP.REQ.URL.QUERY.SET_TEXT_MODE(IGNORECASE).CONTAINS(“CallName=DisplayResults”))

Finally, you would bind the rewrite policies, assigning the first a priority of 600 and the second a priority of 700, and then set the goto expression to NEXT for both bindings.

The Citrix ADC now handles these search requests exactly as the Web server did before the Apache rewrite module rules were migrated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:70 次

字数:3313

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文