【问题标题】:cq5/aem url rewriting or mapping dispatcher and apache web servercq5/aem url 重写或映射调度程序和 apache web 服务器
【发布时间】:2016-04-12 18:53:59
【问题描述】:

我是使用选择器重写 cq5/aem url 的新手。我有以下场景要实现。你能帮我怎么做吗?

我需要请求一个 URL,例如

http://localhost:4502/batteries/toyota/corolla/2011/LE/

应该转换成

http://localhost:4502/content/myprojectroot/project1/en/batteries/search-results.toyota.corolla.2011.LE.html

使用 apache web server/dispatcher 配置和 cq5/aem (etc/map)。请帮助我如何实现这一目标。

【问题讨论】:

    标签: webserver aem dispatcher sling


    【解决方案1】:

    如果你在/etc/map下定义一个节点如下,发布者上的过滤器会重新路由请求:

    <?xml version="1.0" encoding="UTF-8"?>
    <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
              jcr:primaryType="sling:Mapping"
              sling:internalRedirect="[/content/myprojectroot/project1/en/batteries/search-results.$1.$2.$3.$4.html]"
              sling:match=".+/batteries/(.*)/(.*)/(.*)/(.*)/"/>
    

    此 sling.match 允许您匹配组,然后使用 $1 语法捕获该匹配部分以在重新路由 URL 中使用。

    然后您只需要确保调度程序允许初始 URL 模式。一旦调度器完成它的工作,它就会将请求发送给发布者,然后在发布者上,地图重定向将在处理请求时发生。

    另见https://docs.adobe.com/docs/en/aem/6-1/deploy/configuring/resource-mapping.htmlhttps://docs.adobe.com/docs/en/dispatcher/disp-config.html

    【讨论】:

      【解决方案2】:

      使用 apache mod_rewrite 修改发送器的 url!

      【讨论】:

        【解决方案3】:

        在您的 Vhost 上使用如下重写规则:

        RewriteRule ^/batteries/toyota/corolla/2011/LE/ /content/myprojectroot/project1/en/batteries/search-results.toyota.corolla.2011.LE.html [R=301,L]
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2012-08-11
          • 1970-01-01
          • 2010-11-23
          • 1970-01-01
          • 2011-12-31
          • 1970-01-01
          • 1970-01-01
          • 2023-03-15
          相关资源
          最近更新 更多