在CQ5 / AEM URL重写方案中我缺少什么? [英] What am I missing for this CQ5/AEM URL rewriting scenario?

查看:107
本文介绍了在CQ5 / AEM URL重写方案中我缺少什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本上希望短网址得到解析,并希望使用CQ5网站的短网址生成HTML页面。到目前为止,短URL已按预期映射到长URL,但是生成的HTML页面中的链接并未缩短。

I basically want short URLs to get resolved and HTML pages to be generated with short URLs for a CQ5 website. So far short URLs are getting mapped to long URLs as expected, but links in the generated HTML pages are not getting shortened.

例如,我期望以下< script>的 src 属性标记:

For example, I am expecting the src attribute of the following <script> tag:

<script type="text/javascript" src="/content/foo/c0/06/9d/3d93a858-efb4-4619-8f9e-5edc65d0f5ae/style/clientlibs.1395978029951.js"></script>

要缩短为:

<script type="text/javascript" src="/style/clientlibs.1395978029951.js"></script>

但这不是,而且仍然完整。锚元素中的 href 属性也不会缩短。

But it is not and remains intact. href attributes in anchor elements are not getting shortened either.

在JCR中,网站存储在<$ c下$ c> / content / foo / c0 / 06 / 9d / 3d93a858-efb4-4619-8f9e-5edc65d0f5ae / 并且我已经配置了 / etc / hosts 和Apache配置文件,以使其可以在我的本地开发环境中通过 http:// site-1:4503 进行访问。

In JCR, the website is stored under /content/foo/c0/06/9d/3d93a858-efb4-4619-8f9e-5edc65d0f5ae/ and I have configured my /etc/hosts and Apache config files to make it accessible via http://site-1:4503 in my local development environment.

我定义了以下URL映射:

I have defined the following URL mappings:

{
   "jcr:primaryType":"sling:Folder",
   "http":{
      "jcr:primaryType":"sling:Folder",
      "site-1.4503":{
         "sling:internalRedirect":[
            "/content/foo/c0/06/9d/3d93a858-efb4-4619-8f9e-5edc65d0f5ae"
         ],
         "jcr:primaryType":"sling:Mapping",
         "redirect":{
            "sling:internalRedirect":[
               "/content/foo/c0/06/9d/3d93a858-efb4-4619-8f9e-5edc65d0f5ae/$1",
               "/$1"
            ],
            "jcr:primaryType":"sling:Mapping",
            "sling:match":"(.+)$"
         }
      },
      "site_1.4503":{
         "sling:internalRedirect":[
            "/content/foo/c0/06/9d/3d93a858-efb4-4619-8f9e-5edc65d0f5ae/home.html"
         ],
         "jcr:primaryType":"sling:Mapping",
         "sling:match":"site-1.4503/$"
      }
   }
}

当我在JCR Resolver中测试此映射时( http:// localhost:4503 / system / console / jcrresolver ),它按预期运行。例如,

When I test this mapping in JCR Resolver (http://localhost:4503/system/console/jcrresolver), it is working as expected. For example,

/content/foo/c0/06/9d/3d93a858-efb4-4619-8f9e-5edc65d0f5ae/style/clientlibs.1395978029951.js

已映射到

http://site-1:4503/style/clientlibs.1395978029951.js

http://site-1:4503/style/clientlibs.1395978029951.js

解析为:

JcrNodeResource, 
type=cq:ClientLibraryFolder,
superType=null, 
path=/content/foo/c0/06/9d/3d93a858-efb4-4619-8f9e-5edc65d0f5ae/style/clientlibs

另外,当我转到 http://在我的浏览器中,site-1:4503 / style / clientlibs.1395978029951.js 会按预期方式呈现JS文件。

Also when I go to http://site-1:4503/style/clientlibs.1395978029951.js in my browser, the JS file is rendered as expected.

但是当我如我前面所述,查看主页的HTML源代码,没有一个长URL会被重写为它们的缩短形式。

However when I view the HTML source for the home page, as I mentioned earlier, none of the long URLs are rewritten to their shortened forms.

有什么想法我在这里缺少什么?

Any ideas what am I missing here?

推荐答案

我们终于设法找出问题并解决了。

We finally managed to pinpoint the issue and fix this.

有人添加了 /apps/myapp/config.publish com.day.cq.rewriter.linkchecker.impl.LinkCheckerImpl.xml >,其中包含以下内容:

Somebody had added a com.day.cq.rewriter.linkchecker.impl.LinkCheckerImpl.xml under /apps/myapp/config.publish with the following content:

<?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:OsgiConfig"
    service.bad_link_tolerance_interval="{Long}48"
    service.check_override_patterns="[^.]"
    service.special_link_patterns=".*&#xa;"
    service.special_link_prefix="[javascript:,data:,mailto:,#,&lt;!--,${]"/>

我认为 check_override_patterns special_link_patterns 禁用了链接缩短。

I think the combination of check_override_patterns and special_link_patterns had disabled link shortening.

删除此文件使链接缩短再次起作用。

Removing this file made link shortening work again.

这篇关于在CQ5 / AEM URL重写方案中我缺少什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆