Expand my Community achievements bar.

SOLVED

Trouble setting up Dispatcher with vhost config and sling mappings

Avatar

Level 4

https://dev.day.com/docs/en/cq/current/deploying/dispatcher/disp_domains.html

Hi,

I am trying to setup my web dispatcher so that users who browse to http://myserver.com will go through the following process

1. client gets routed to http://myserver.com/index.html

2. web server will check dispatcher to see if /var/www/htdocs/content/site/index.html exists.  if exists, serve page.  if does not exist, go to 3.

3. dispatcher routes to the publish instance and get /content/site/index.html from the repository and serve

The following is my vhost configuration

NameVirtualHost *:80

<VirtualHost *:80>
  ServerName web-qa-01
  DocumentRoot "/var/www/html/content/site"
  RewriteEngine  on
  RewriteRule ^/$ /content/site/index.html [PT,L]
  RewriteRule ^/(.*)$ /content/site/$1 [PT,L]
   <Directory /var/www/html/content/site>
     <IfModule disp_apache2.c>
       SetHandler dispatcher-handler
       ModMimeUsePathInfo On
     </IfModule>
     Options FollowSymLinks
     AllowOverride None
   </Directory>
</VirtualHost>

I have my dispatcher.any set to use /docroot "/var/www/html/content/site" 

On my publish instance, I added the following sling:Mappings

/etc/map/http/web-qa-01

--sling:internalRedirect = /content/site/index.html

--sling:match = web-qa-01/$

When I hit my site with a browser, I see web-qa-01/content/geometrixx-outdoors/en.html.  From the apache's access logs, I see that the following event sequence

137.XX.XX.XX - - [01/Jan/2014:15:39:17 -0800] "GET / HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0"
137.XX.XX.XX - - [01/Jan/2014:15:39:17 -0800] "GET /index.html HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0"
137.XX.XX.XX - - [01/Jan/2014:15:39:18 -0800] "GET /content.html HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0"
137.XX.XX.XX - - [01/Jan/2014:15:39:19 -0800] "GET /geohome.html HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0"
137.XX.XX.XX - - [01/Jan/2014:15:39:19 -0800] "GET /content/geometrixx-outdoors.html HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0"
137.XX.XX.XX - - [01/Jan/2014:15:39:20 -0800] "GET /content/geometrixx-outdoors/en.html HTTP/1.1" 304 - "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0"

I know it goes to /geohome.html because /content.html has a target to route to /geohome.html.  However, shouldn't the sling;Mappings created in the publish instance ignore this?  What am I missing?

Thank You.

1 Accepted Solution

Avatar

Correct answer by
Level 5

This mean that your sling:mapping is not getting matched with request. May be try this,

 

<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"

    jcr:primaryType="sling:Mapping"

    sling:internalRedirect="/content/site/index.html"

    sling:match=".*web-qa-01.(4503|80)+/$"/>

 

If this does not work change "Day CQ Root Mapping" config from config manager to point to /content/site/index.html

 

Also I feel that your this rewrite rule is wrong for request with /content in it,

 

RewriteRule ^/(.*)$ /content/site/$1 [PT,L]

You should exclude any thing that starts with /content in this rule, Something like (otherwise you might have /content/site appended to that requested as well.

 

RewriteCond %{REQUEST_URI} !^/content/dam(.*) [NC]

RewriteCond %{REQUEST_URI} !^/etc(.*) [NC]

RewriteCond %{REQUEST_URI} !^/content/campaigns(.*) [NC]

RewriteCond %{REQUEST_URI} !^/content/site(.*) [NC]

RewriteRule ^/(.*)$ /content/site/$1 [PT,L]

 

Yogesh

View solution in original post

2 Replies

Avatar

Correct answer by
Level 5

This mean that your sling:mapping is not getting matched with request. May be try this,

 

<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"

    jcr:primaryType="sling:Mapping"

    sling:internalRedirect="/content/site/index.html"

    sling:match=".*web-qa-01.(4503|80)+/$"/>

 

If this does not work change "Day CQ Root Mapping" config from config manager to point to /content/site/index.html

 

Also I feel that your this rewrite rule is wrong for request with /content in it,

 

RewriteRule ^/(.*)$ /content/site/$1 [PT,L]

You should exclude any thing that starts with /content in this rule, Something like (otherwise you might have /content/site appended to that requested as well.

 

RewriteCond %{REQUEST_URI} !^/content/dam(.*) [NC]

RewriteCond %{REQUEST_URI} !^/etc(.*) [NC]

RewriteCond %{REQUEST_URI} !^/content/campaigns(.*) [NC]

RewriteCond %{REQUEST_URI} !^/content/site(.*) [NC]

RewriteRule ^/(.*)$ /content/site/$1 [PT,L]

 

Yogesh

Avatar

Level 4

Yogesh Upadhyay wrote...

This mean that your sling:mapping is not getting matched with request. May be try this,

 

<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"

    jcr:primaryType="sling:Mapping"

    sling:internalRedirect="/content/site/index.html"

    sling:match=".*web-qa-01.(4503|80)+/$"/>

 

If this does not work change "Day CQ Root Mapping" config from config manager to point to /content/site/index.html

 

Also I feel that your this rewrite rule is wrong for request with /content in it,

 

RewriteRule ^/(.*)$ /content/site/$1 [PT,L]

You should exclude any thing that starts with /content in this rule, Something like (otherwise you might have /content/site appended to that requested as well.

 

RewriteCond %{REQUEST_URI} !^/content/dam(.*) [NC]

RewriteCond %{REQUEST_URI} !^/etc(.*) [NC]

RewriteCond %{REQUEST_URI} !^/content/campaigns(.*) [NC]

RewriteCond %{REQUEST_URI} !^/content/site(.*) [NC]

RewriteRule ^/(.*)$ /content/site/$1 [PT,L]

 

Yogesh

 


Thank You Yogesh.  After updating my sling:match to read ".*web-qa-01.(4503|80)+/$", I am able to get to the site I wanted when I type in web-qa-01.