Expand my Community achievements bar.

SOLVED

Dispatcher Root Mapping

Avatar

Level 1

How can I set the default page for a dispatcher?

In the past, our site was using a load balancer with the publishers, and the Day CQ Root Mapping setting handled the page to load when the base URL was hit. We're moving to a dispatcher on a rebuild of the site, and the root mapping doesn't seem to be working. 

Everything I can find regarding URLs for the dispatcher is about rewriting the displayed URL as best as I can tell, but I don't understand how to define the primary page for the site. Is that a setting for the dispatcher or on the server? Will URL mapping from the primary domain to the page we want to be the home page solve this problem?

Additionally, if URL mapping is what I need to do, we're currently just using the dispatcher URL for testing but will be setting a different URL when we switch over. Is there a way to map URLs for both domains for sling:match?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

 hi @juliat95115877 ,

 

If you are using apache server with dispatcher, you can use apache's rewrite rule to redirect ROOT request to sitte home page. Dispatcher is just the module but actual redirection should be handled using apache server only. Find below the sample rewrite rule which you can use:

#Redirect Root page request to home page
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{HTTP_HOST} ^(mysite.com)$ [NC]
RewriteRule ^/ https://%{HTTP_HOST}/en/home.html [L,R=301]

 

  • You will have to enable rewrite module on apache fiest
  • you can then modify apache rule and add it to vhost file of your site
  • Here 301 that is permanent redirection will make sure to redirect any further root request to home page 

Hope it helps!

Nupur

View solution in original post

6 Replies

Avatar

Community Advisor

Hi,

Why don't you set home page directly on Apache. Whenever there is a request for /, you can remap to home page.



Arun Patidar

Avatar

Level 1
I wasn't sure if that was the correct approach. I don't have direct access to Apache and have to go through another team for that.

Avatar

Employee

If you are using Apache, you can use the mod_rewrite module to specify a default page /homepage. See the Apache web site documentation for information about mod_rewrite (for example, Apache 2.4 ). When using mod_rewrite , it is advisable to use the flag 'passthrough|PT' (pass through to next handler) to force the rewrite engine to set the uri field of the internal request_rec structure to the value of the filename field.

Avatar

Correct answer by
Community Advisor

 hi @juliat95115877 ,

 

If you are using apache server with dispatcher, you can use apache's rewrite rule to redirect ROOT request to sitte home page. Dispatcher is just the module but actual redirection should be handled using apache server only. Find below the sample rewrite rule which you can use:

#Redirect Root page request to home page
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{HTTP_HOST} ^(mysite.com)$ [NC]
RewriteRule ^/ https://%{HTTP_HOST}/en/home.html [L,R=301]

 

  • You will have to enable rewrite module on apache fiest
  • you can then modify apache rule and add it to vhost file of your site
  • Here 301 that is permanent redirection will make sure to redirect any further root request to home page 

Hope it helps!

Nupur

Avatar

Community Advisor

Hi Nupur,

 

# custom rewrites
#Redirect Root page request to home page
RewriteCond %{REQUEST_URI} ^/$
RewriteRule (.*) /content/abc/us/en/home-page.html [PT,L]

 

I wrote the above rule in my vhost file but get the below error log in dispatcher

172.17.0.1 "domainname:8080" - [27/Jul/2022:11:40:29 +0000] "GET / HTTP/1.1" 404 5615 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0"
[27/Jul/2022:11:40:29 +0000] "GET /content/abc/us/en/errors/404.html HTTP/1.1" - hit [publishfarm/-] 15ms "domainname:8080"

I have defined an Error Document directive too as below - 

ErrorDocument 404 /content/abc/us/en/errors/404.html

Can you help as to why the redirect is not working ?