Aem 网址缩短

Aem 网址缩短,aem,sling,Aem,Sling,我们有一个多语言网站,其结构类似于/content///login page,我希望从URL中删除/content//和.html,这样就不用访问http://www.application.com/content//en/login-page.html或http://www.application.es/content//en/login-page.html我可以像http://www.application.com/login-page和http://www.application.es/l

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

这里有一篇关于这方面的优秀文章:

由于您有两个域,因此需要在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/$1","/$1"],
         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/$1","/$1"],
         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/$1 [PT,L]
    </VirtualHost>    
  <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/$1 [PT,L]
    </VirtualHost>      

服务器管理员webmaster@localhost
服务器名www.application.com
DocumentRoot/opt/cq/dispatcher/publish
选项如下符号链接
不允许超限
SetHandler调度程序
重新启动发动机
重写规则^/$/content/application/en.html[PT,L]
重写cond%{REQUEST_URI}^/应用程序
重写cond%{REQUEST_URI}^/箱子
重写cond%{REQUEST_URI}^/内容
重写cond%{REQUEST_URI}^/等
重写cond%{REQUEST_URI}^/家
重写cond%{REQUEST_URI}^/自由基
重写cond%{REQUEST_URI}^/tmp
重写cond%{REQUEST_URI}^/变量
重写规则^/(.*)$/content/application/en/$1[PT,L]
在web服务器中重写.es的规则:

    <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/$1 [PT,L]
    </VirtualHost>    
  <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/$1 [PT,L]
    </VirtualHost>      

服务器管理员webmaster@localhost
服务器名www.application.es
DocumentRoot/opt/cq/dispatcher/publish
选项如下符号链接
不允许超限
SetHandler调度程序
重新启动发动机
重写规则^/$/content/application/es.html[PT,L]
重写cond%{REQUEST_URI}^/应用程序
重写cond%{REQUEST_URI}^/箱子
重写cond%{REQUEST_URI}^/内容
重写cond%{REQUEST_URI}^/等
重写cond%{REQUEST_URI}^/家
重写cond%{REQUEST_URI}^/自由基
重写cond%{REQUEST_URI}^/tmp
重写cond%{REQUEST_URI}^/变量
重写规则^/(.*)$/content/application/es/$1[PT,L]
[所有规则均已根据上述链接进行了修改]

无扩展url在Sling中不起作用,所以您必须从Web服务器重新编写url以添加它们,然后 在aem中编写linktransformer,将它们从html中的链接中删除,下面是一篇文章的链接,解释了这一点

谢谢Sharath。我有一个问题。缩短URL和使用虚荣URL的区别是什么。我的意思是,我不会只是使用虚荣URL,避免所有的努力。虚荣URL是用来在特殊情况下使用的。例如,有一个页面包含折扣产品列表,您希望发送一封带有醒目url的邮件,如example.com/flat50。它们在整个服务器中必须是唯一的。因此,如果没有.com和.es/flat50的映射,将失败。所有url都有虚荣路径可能会对性能产生影响(因为每个请求都必须根据一个庞大的列表进行检查。免责声明:此结论基于我对其工作原理的理解,我可能是错的)请检查此链接:。感谢您提供的信息。这就解释了。还要注意,虚荣URL可以是内部重定向,也可以是外部302重定向。使用sling:Mapping,您可以将状态代码设置为300、301、302、303或307。