首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AEM: URL缩短

AEM: URL缩短
EN

Stack Overflow用户
提问于 2015-03-10 15:16:05
回答 1查看 9.5K关注 0票数 2

我们有一个像/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映射中的映射是什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-11 03:00:12

这里有一篇很好的文章:

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

因为您有两个域,所以在etc/map中需要两个映射。就像这样:

代码语言:javascript
复制
{
   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规则:

代码语言:javascript
复制
    <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>    

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

代码语言:javascript
复制
  <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>      

所有规则都是从上面提到的链接中修改的。

没有扩展的url在Sling中不起作用,所以您必须重新编写webserver中的url来添加它们,然后在http://www.citytechinc.com/us/en/blog/2013/04/extensionless-urls-in-adobe-experience-manager.html中编写链接转换器以从html中的链接中删除它们,这里有一个链接到一个解释这个的帖子

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28967432

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档