我想了解 sling url 重写是如何工作的。我正在关注这个网址 -
http://www.cognifide.com/blogs/cq/multidomain-cq-mappings-and-apache-configuration/ http://www.cognifide.com/blogs/cq/multidomain-cq-mappings-and-apache-configuration/
我在发布环境中完成的步骤 -
/etc/map.publish/http:
jcr: primaryType: "sling:OrderedFolder",
home: {
sling:internalRedirect: ["/content/geometrixx/en.html"],
jcr:primaryType: "sling:Mapping",
sling:match: "localhost:4503/$"
},
localhost.4503: {
sling:internalRedirect: ["/content/geometrixx/en"],
jcr:primaryType: "sling:Mapping",
redirect: {
sling:internalRedirect: ["/content/geometrixx/en/$1","/$1"],
jcr:primaryType: "sling:Mapping",
sling:match: "(.+)$"
}
}
1)但是,当我点击这个网址时:
http://localhost:4503/products.html then I got 404 error.
2)此外,我想在用户点击此网址时实现:
http://localhost:4503/content/geometrixx/en.html then it should open
http://localhost:4503/en/products.html.
请告诉我是否可以按照上述方法
Update:我正在尝试通过调度程序访问。我在 Windows 7、CQ5.6.0 上使用 Apache 2.0。我的 httpd.conf 如下所示 -
<IfModule disp_apache2.c>
DispatcherConfig conf/dispatcher.any
DispatcherLog logs/dispatcher.log
DispatcherLogLevel 3
DispatcherNoServerHeader 0
DispatcherDeclineRoot 0
DispatcherUseProcessedURL 0
DispatcherPassError 0
</IfModule>
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/Apache2/htdocs/content/sitea"
RewriteEngine On
RewriteRule ^/$ /content/geometrixx/en.html [PT,L]
RewriteCond %{REQUEST_URI} !^/apps
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/geometrixx/en/$1 [PT,L]
<Directory "C:/Apache2/htdocs/content/sitea">
<IfModule disp_apache2.c>
SetHandler dispatcher-handler
ModMimeUsePathInfo On
</IfModule>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
3)现在,当我点击:localhost/content/geometrixx/en/products.html时,我会得到该页面,并且调度程序也会缓存该页面。但是,如果我导航到任何页面(例如“产品”->“三角形”),则由于 Sling 映射,URL 将变为 localhost:4503/products/triangle.html。这是预期的吗?由于dispatch不知道Sling映射,因此它不缓存triangle.html。如何使调度程序缓存工作?
4)由于存在重写规则(RewriteRule ^/(.*)$ /content/geometrixx/en/$1 [PT,L]),如果我点击此网址 localhost/triangle.html 那么我应该得到正确的页面localhost/content/geometrixx/en/triangle.html 但我收到 404 错误。