Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

doubts on dispatcher cache and mod rewrite

Avatar

Level 6

I've configured Sling mapping in publish instance and its working fine. 

{ "jcr:primaryType": "sling:OrderedFolder", "home": { "sling:internalRedirect": "/content/geometrixx/en.html", "sling:match": "localhost.4503/$", "jcr:primaryType": "sling:Mapping", }, "localhost.4503": { "sling:internalRedirect": "/content/geometrixx/en", "jcr:primaryType": "sling:Mapping", "redirect": { "sling:internalRedirect": [ "/content/geometrixx/en/$1", "/$1" ], "sling:match": "(.+)$", "jcr:primaryType": "sling:Mapping", } } }

I'm trying to access through dispatcher. I'm using Apache 2.0 on windows 7, CQ5.6.0. My httpd.conf looks like below - 

<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>

Q1) Now, when I hit : localhost/content/geometrixx/en/products.html then I get the page and dispatcher also cache the page. But after if I navigate to any page for example Products ->Triangle then URL becomes localhost:4503/products/triangle.html due to Sling mapping. is this expected? As dispatch does not know about Sling mapping hence it does not cache triangle.html. How to make dispatcher cache work?

Q2) As the rewriter rule is there(RewriteRule ^/(.*)$ /content/geometrixx/en/$1 [PT,L]), if I hit this url localhost/triangle.html then I should get the proper page as localhost/content/geometrixx/en/triangle.html but I get 404 error.

Kindly let me know what I'm missing here. 

1 Accepted Solution

Avatar

Correct answer by
Level 8

The DispatcherUseProcessedURL property in dispatcher.any controls whether Dispatcher uses the requested URL or the mod-rewritten URL. The URL that it uses is compared to the filters in dispatcher.any, and it also dictates the directory structure of the cache. 

My advice is to (at least at first) use one of Sling mapping or mod_rewrite, get it working, and then experiment with mixing them if you so desire  :)

 

scott 

View solution in original post

6 Replies

Avatar

Correct answer by
Level 8

The DispatcherUseProcessedURL property in dispatcher.any controls whether Dispatcher uses the requested URL or the mod-rewritten URL. The URL that it uses is compared to the filters in dispatcher.any, and it also dictates the directory structure of the cache. 

My advice is to (at least at first) use one of Sling mapping or mod_rewrite, get it working, and then experiment with mixing them if you so desire  :)

 

scott 

Avatar

Level 6

I was able to make sling mapping and mod_rewrite work individually but not both :(  

Avatar

Level 6

Yes, dispatcher.any - 

/farms
  {
  /sitea 
    {  
    /clientheaders
      {  "*"  }
    /virtualhosts  { "localhost" }
    /renders
      {  /rend01   {  /hostname "localhost"    /port "4503"  }
      }
    /filter
      {        /0001 { /type "deny" /glob "*" }
         /0023 { /type "allow" /url "/content*" }  # disable this rule to allow mapped content only
      /0041 { /type "allow" /url "*.css"   }  # enable css
      /0042 { /type "allow" /url "*.gif"   }  # enable gifs
      /0043 { /type "allow" /url "*.ico"   }  # enable icos
      /0044 { /type "allow" /url "*.js"    }  # enable javascript
      /0045 { /type "allow" /url "*.png"   }  # enable png
      /0046 { /type "allow" /url "*.swf"   }  # enable flash
      /0047 { /type "allow" /url "*.jpg"   }  # enable jpg
      /0048 { /type "allow" /url "*.jpeg"  }  # enable jpeg
     /0062 { /type "allow" /url "/libs/cq/personalization/*"  }  # enable personalization

      /0081 { /type "deny"  /url "*.infinity.json" }
      /0082 { /type "deny"  /url "*.tidy.json"     }
      /0083 { /type "deny"  /url "*.sysview.xml"   }
      /0084 { /type "deny"  /url "*.docview.json"  }
      /0085 { /type "deny"  /url "*.docview.xml"  }
      
      /0086 { /type "deny"  /url "*.*[0-9].json" }
#     /0087 { /type "allow" /method "GET" /url "*.1.json" }  # allow one-level json requests

      # Deny query
      /0090 { /type "deny"  /url "*.query.json" }
      /0091 { /type "allow"  /glob "* /bin/flushcache/*" }
      }
 /cache
      {
      /docroot "C:/Apache2/htdocs/content/sitea"
      /statfileslevel "2"
      
       /rules
        {
        /0000
          {
          /glob "*"
          /type "allow"
          }
        }
      /invalidate
        {
        /0000
          {
          /glob "*"
          /type "deny"
          }
        /0001
          {
          /glob "*.html"
          /type "allow"
          }
        /0002
          {
          /glob "/etc/segmentation.segment.js"
          /type "allow"
          }
        /0003
          {
          /glob "*/analytics.sitecatalyst.js"
          /type "allow"
          }
        }

      /allowedClients
        {
        
        }
            
      }
      
    /statistics
      {
      /categories
        {
        /html
          {
          /glob "*.html"
          }
        /others
          {
          /glob "*"
          }
        }
      }
    }

Avatar

Level 8

I just noticed that you are using Sling mapping as well as Apache rewrites...you only need to use one or the other. Is there a reason that you use both? The doc page I linked to shows how to configure Dispatcher for both scenarios.

scott

Avatar

Level 6

Thanks Scott for prompt reply. I was doing this just for experiment purpose. Is it not possible to use both Sling mapping and Apache rewrite?  I followed that links you mentioned but unable to make dispatcher cache work with mod rewrite and sling mapping enable. I tried to use DispatcherUseProcessedURL 1 but it did not help. 

I appreciate your help  

 

Sam