我们有一个像/content/<app>/<language>/login-page这样的多语言网站,我想从URL中去掉/content/<app>/<language>和.html,这样我就可以访问像http://www.application.com/content/<app>/en/login-page.html或http://www.application.es/content/<app>/en/login-page.html这样的页面,比如http://www.application.com/login-page和http://www.application.es/login-page。据我所知,这需要在Apache中使用Sling映射和重写规则。但不太确定如何实现这一目标。apache和Sling映射中的映射是什么?
发布于 2015-03-11 03:00:12
这里有一篇很好的文章:
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/$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> 在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/$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中的链接中删除它们,这里有一个链接到一个解释这个的帖子
https://stackoverflow.com/questions/28967432
复制相似问题