AEM:URL 缩短

AEM: URL Shortening

我们有一个结构类似于 /content/<app>/<language>/login-page 的多语言网站,我希望从 URL 中删除 /content/<app>/<language> 和 .html ,这样就不用访问http://www.application.com/content/<app>/en/login-page.htmlhttp://www.application.es/content/<app>/en/login-page.html 之类的页面 我可以访问 http://www.application.com/login-pagehttp://www.application.es/login-page 之类的页面。据我所知,这必须在 Apache 中使用 Sling 映射和重写规则来处理。但不确定如何实现这一目标。 apache 和 Sling 映射中的映射是什么?

这里有一篇关于此的精彩文章:

http://www.cognifide.com/blogs/cq/multidomain-cq-mappings-and-apache-configuration#.VP-psmSUc44

由于您有两个域,因此您需要在 etc/map 中进行两个映射。像这样:

{
   jcr: primaryType: "sling:OrderedFolder",
    www.application_com: {
     sling:internalRedirect: ["/content/application/en.html"],                               
     jcr:primaryType: "sling:Mapping",
     sling:match: "www.application.com/$"
    },
    www.application.com: {
      sling:internalRedirect: ["/content/application/en"],         
      jcr:primaryType: "sling:Mapping",
      redirect: {
         sling:internalRedirect: ["/content/application/en/","/"],
         jcr:primaryType: "sling:Mapping",
         sling:match: "(.+)$"
       }
    },
    www.application_es: {
     sling:internalRedirect: ["/content/application/es.html"],                               
     jcr:primaryType: "sling:Mapping",
     sling:match: "application.com/$"
    },
    www.application.es: {
      sling:internalRedirect: ["/content/application/es"],         
      jcr:primaryType: "sling:Mapping",
      redirect: {
         sling:internalRedirect: ["/content/application/es/","/"],
         jcr:primaryType: "sling:Mapping",
         sling:match: "(.+)$"
       }
    },
}

在 Web 服务器中重写 .com 的规则:

    <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName www.application.com

        DocumentRoot /opt/cq/dispatcher/publish
        <Directory /opt/cq/dispatcher/publish>
            Options FollowSymLinks
            AllowOverride None
        </Directory>

        <IfModule disp_apache2.c>
            SetHandler dispatcher-handler
        </IfModule>
        RewriteEngine On
           RewriteRule ^/$ /content/application/en.html [PT,L]
           RewriteCond %{REQUEST_URI} !^/apps
           RewriteCond %{REQUEST_URI} !^/bin
           RewriteCond %{REQUEST_URI} !^/content
           RewriteCond %{REQUEST_URI} !^/etc
           RewriteCond %{REQUEST_URI} !^/home
           RewriteCond %{REQUEST_URI} !^/libs
           RewriteCond %{REQUEST_URI} !^/tmp
           RewriteCond %{REQUEST_URI} !^/var
           RewriteRule ^/(.*)$ /content/application/en/ [PT,L]
    </VirtualHost>    

在 Web 服务器中重写 .es 的规则:

  <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName www.application.es

        DocumentRoot /opt/cq/dispatcher/publish
        <Directory /opt/cq/dispatcher/publish>
            Options FollowSymLinks
            AllowOverride None
        </Directory>

        <IfModule disp_apache2.c>
            SetHandler dispatcher-handler
        </IfModule>
        RewriteEngine On
           RewriteRule ^/$ /content/application/es.html [PT,L]
           RewriteCond %{REQUEST_URI} !^/apps
           RewriteCond %{REQUEST_URI} !^/bin
           RewriteCond %{REQUEST_URI} !^/content
           RewriteCond %{REQUEST_URI} !^/etc
           RewriteCond %{REQUEST_URI} !^/home
           RewriteCond %{REQUEST_URI} !^/libs
           RewriteCond %{REQUEST_URI} !^/tmp
           RewriteCond %{REQUEST_URI} !^/var
           RewriteRule ^/(.*)$ /content/application/es/ [PT,L]
    </VirtualHost>      

[所有规则均改编自上述link]

Extensionless url 在 Sling 中不起作用,因此您必须从网络服务器重新编写 url 以添加它们,然后 在 aem 中写入 linktransformer 以从 html 中的 links 中删除它们,这里有一个 link 到 post 来解释这个 http://www.citytechinc.com/us/en/blog/2013/04/extensionless-urls-in-adobe-experience-manager.html