Redirect the url https://tooB.com.br and https://tooBB.com to https://tooA.com (vhost and dispatcher ?) | Community
Skip to main content
Level 2
October 28, 2024
Solved

Redirect the url https://tooB.com.br and https://tooBB.com to https://tooA.com (vhost and dispatcher ?)

  • October 28, 2024
  • 2 replies
  • 1405 views
I have 3 url's with the same content, that is, the 3 sites have the same content, but I would like any user to access the url's https://tooB.com.br or https://tooBB. com were redirected to the URL https://tooA.com in your browser, simple as that.
I was told to change my dispatcher -> src -> conf.d -> available_vhosts
In this path I have two files, default.vhost and too.vhosts, both with almost the same content, the difference is that default.vhost is as follows:

# Include customer defined variables
Include conf.d/variables/custom.vars
 
<VirtualHost *:80>
ServerName "publish"
# Put names of which domains are used for your published site/content here
ServerAlias "*"
# Use a document root that matches the one in conf.dispatcher.d/default.farm
DocumentRoot "${DOCROOT}"
# URI dereferencing algorithm is applied at Sling's level, do not decode parameters here
AllowEncodedSlashes NoDecode
# Add header breadcrumbs for help in troubleshooting
<IfModule mod_headers.c>
Header add X-Vhost "publish"
</IfModule>
 
 
 
and too.vhost looks like this:
 
# Include customer defined variables
Include conf.d/variables/custom.vars
 
<VirtualHost *:80>
ServerName https://tooA.com
# Put names of which domains are used for your published site/content here
# Use a document root that matches the one in conf.dispatcher.d/default.farm
DocumentRoot "${DOCROOT}"
# URI dereferencing algorithm is applied at Sling's level, do not decode parameters here
AllowEncodedSlashes NoDecode
# Add header breadcrumbs for help in troubleshooting
<IfModule mod_headers.c>
Header add X-Vhost "publish"
</IfModule>
 
 
 

But even if the user enters the 3 URLs in the browser search, the entered URL always returns, that is, if he accesses by typing https://tooBB.com, https://tooBB.com will appear in the url field,
If he types in the search https://tooB.com.br https://tooB.com.br will appear.

 

What I mean is that when the user types in the search https://tooB.com.br or https://tooBB.com, the url is automatically changed to https://tooA.com

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

Hi @evertonsa2,

that is expected, as both domains are added as aliases in your VHOST. Therefore, they are supported, not redirected. You should be able to achieve what you need with an Apache rewrite rule, something like:

 

# Redirect from tooB.com.br RewriteCond %{HTTP_HOST} ^(www\.)?tooB\.com\.br$ [NC] RewriteRule ^(.*)$ https://tooA.com/$1 [L,R=301] # Redirect from tooBB.com RewriteCond %{HTTP_HOST} ^(www\.)?tooBB\.com$ [NC] RewriteRule ^(.*)$ https://tooA.com/$1 [L,R=301]

 

These are examples of 301 redirect rules that can be added to your too.vhost file.

 

Hope this helps,

Daniel

2 replies

daniel-strmecki
Community Advisor and Adobe Champion
daniel-strmeckiCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
October 28, 2024

Hi @evertonsa2,

that is expected, as both domains are added as aliases in your VHOST. Therefore, they are supported, not redirected. You should be able to achieve what you need with an Apache rewrite rule, something like:

 

# Redirect from tooB.com.br RewriteCond %{HTTP_HOST} ^(www\.)?tooB\.com\.br$ [NC] RewriteRule ^(.*)$ https://tooA.com/$1 [L,R=301] # Redirect from tooBB.com RewriteCond %{HTTP_HOST} ^(www\.)?tooBB\.com$ [NC] RewriteRule ^(.*)$ https://tooA.com/$1 [L,R=301]

 

These are examples of 301 redirect rules that can be added to your too.vhost file.

 

Hope this helps,

Daniel

Level 2
October 28, 2024

Hello @daniel-strmecki 

So is this how I have to change my too.vhost ?

 

<VirtualHost *:80> ServerName https://tooA.com # Put names of which domains are used for your published site/content here ServerAlias https://tooB.com.br https://tooBB.com # Use a document root that matches the one in conf.dispatcher.d/default.farm DocumentRoot "${DOCROOT}" # URI dereferencing algorithm is applied at Sling's level, do not decode parameters here AllowEncodedSlashes NoDecode # Add header breadcrumbs for help in troubleshooting <IfModule mod_headers.c> Header add X-Vhost "publish" </IfModule> <Directory /> <IfModule disp_apache2.c> # Some items cache with the wrong mime type # Use this option to use the name to auto-detect mime types when cached improperly ModMimeUsePathInfo On # Use this option to avoid cache poisioning # Sling will return /content/image.jpg as well as /content/image.jpg/ but apache can't search /content/image.jpg/ as a file # Apache will treat that like a directory. This assures the last slash is never stored in cache DirectorySlash Off # Enable the dispatcher file handler for apache to fetch files from AEM SetHandler dispatcher-handler # Redirect from tooB.com.br RewriteCond %{HTTP_HOST} ^(www\.)?tooB\.com\.br$ [NC] RewriteRule ^(.*)$ https://tooA.com/$1 [L,R=301] # Redirect from tooBB.com RewriteCond %{HTTP_HOST} ^(www\.)?tooBB\.com$ [NC] RewriteRule ^(.*)$ https://tooA.com/$1 [L,R=301] </IfModule>

 

Tethich
Community Advisor
Community Advisor
October 28, 2024

Hi @evertonsa2 
I believe what @daniel-strmecki explained should work and that you got it right in your example.

The only small question mrk I have in my mind is a about the need to have the [NC] or not at the end. That is for case-insensitive matching, but domains by default do not care about case sensitivity, so ..... not sure if really needed. But maybe I am wrong.....

For more Apache flags you can check docs: https://httpd.apache.org/docs/2.4/rewrite/flags.html

arunpatidar
Community Advisor
Community Advisor
October 29, 2024

Hi @evertonsa2 
Are you using CDN, if yes then you can put redirects there and completely remove dispatcher config for 3rd domain.

Arun Patidar
Level 2
November 1, 2024
Hi @arunpatidar 
Do you have any documentation explaining how to perform this redirection via the CDN?

 

daniel-strmecki
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
November 1, 2024

Hi @evertonsa2,

it is documented here: https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/content-delivery/cdn-configuring-traffic#client-side-redirectors

 

You can do redirects both on CDN and Apache, usually closer to the client is better - CDN.

 

Good luck,

Daniel