Dispatcher Root Mapping | Community
Skip to main content
July 9, 2020
Solved

Dispatcher Root Mapping

  • July 9, 2020
  • 4 replies
  • 3781 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Nupur_Jain

 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

4 replies

arunpatidar
Community Advisor
Community Advisor
July 9, 2020

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
July 9, 2020
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.
Level 2
July 10, 2020
vanegi
Adobe Employee
Adobe Employee
July 10, 2020

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.

Nupur_Jain
Adobe Employee
Nupur_JainAdobe EmployeeAccepted solution
Adobe Employee
July 10, 2020

 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

Rohan_Garg
Community Advisor
Community Advisor
July 27, 2022

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 ?