Search code examples
javassladobeaemsling

sling SSL configuration with proper "sling:match"


I am using Adobe CQ 5.6 and implementing SSL configuration according to the following link. http://docs.adobe.com/docs/en/cq/current/deploying/config-ssl.html The SSL is now configured, but not working against a particular URI match. I want any url ends with "abc.html" should open through SSL.

Like : http://localhost:5402/content/xyz/abc.html should replace with https://localhost:5433/content/xyz/abc.html

Now can someone please tell me for above, what should be the value of property "sling:match"


Solution

  • Following mapping should do the trick:

    /etc/map
          +-- http
               +-- localhost.5402
                    +-- abc
                         +-- sling:match = "(.*)/abc.html"
                         +-- sling:redirect = "https://localhost:5433/$1/abc.html"
                         +-- sling:status = "301"
    

    localhost.5402 matches hostname and port. The abc mapping matches all requests with /abc.html suffix and redirects it to the https domain using HTTP status code 301 Moved Permanently.

    You may also consider using Apache's mod_rewrite. Appropriate rules would look like this:

    RewriteCond %{HTTP_HOST}    =localhost
    RewriteCond %{SERVER_PORT}  =5402
    RewriteRule ^/(.*)/abc.html$ https://localhost:5433/$1/abc.html [L,R=301]