Dispatcher URL Rewriting | Community
Skip to main content
Best answer by TarunKumar

Hi @ronnie09 

You can follow below steps:

In httpd conf file:
ServerName sample-project.com:80

In v-host file under <VirtualHost *:80>: -
ServerName sample-project.com
ServerAlias www.sample-project.com

and then rewrite rule as:
RewriteRule ^/(.*)$  /$1 [PT,L]


4 replies

SantoshSai
Community Advisor
Community Advisor
November 29, 2022

Hi @ronnie09 ,

1. Add entry in resource mappings at OSGI config in AEM
/config.publish/org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl.xml
resource.resolver.mapping="[/:/,/content/sample-project/us/en:/]"

2. Add Apache server rewrite rules
RewriteRule ^/$ /content/sample-project/us/en.html [PT,NE,L]
RewriteRule ^/(.*)$ /content/sample-project/learn/$1 [PT,NE]

Hope that helps!

Regards,

Santosh

Santosh Sai
Mani_kumar_
Community Advisor
Community Advisor
November 29, 2022

Defining the virtual host configuration and rewrite rule should fix the problem.

Please refer the document below for more information

https://experienceleague.adobe.com/docs/experience-manager-dispatcher/using/configuring/dispatcher-domains.html?lang=en#define-virtual-hosts-on-the-web-server

 

Avinash_Gupta_
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
November 29, 2022

@ronnie09 This can be handle in two steps.

 

First, you would need to assign your local host a domain name 

https://ecompile.io/blog/localhost-custom-domain-name 

 

Second, add a redirect rule in the dispatcher

 

RewriteRule "^/learn$" "https://%{SERVER_NAME}/content/sample-project/us/en.html" [R,L]

 

Hope this helps.

TarunKumar
Community Advisor
TarunKumarCommunity AdvisorAccepted solution
Community Advisor
November 30, 2022

Hi @ronnie09 

You can follow below steps:

In httpd conf file:
ServerName sample-project.com:80

In v-host file under <VirtualHost *:80>: -
ServerName sample-project.com
ServerAlias www.sample-project.com

and then rewrite rule as:
RewriteRule ^/(.*)$  /$1 [PT,L]