Dispatcher Doubt Regarding Mod Rewrite

Avatar

Avatar
Validate 1
Level 1
binoyp6992037
Level 1

Likes

0 likes

Total Posts

9 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Give Back
View profile

Avatar
Validate 1
Level 1
binoyp6992037
Level 1

Likes

0 likes

Total Posts

9 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Give Back
View profile
binoyp6992037
Level 1

20-06-2021

Hi All,

 

I am exploring dispatcher rewrite rules and i'm fairly new to this.

<IfModule mod_rewrite.c>
#Enable this to debug the redirect logs
RewriteEngine on
 
# remove any trailing slash, if it's there.
RewriteRule ^(.+)/$ $1
 
#Shorten the URL
RewriteRule ^/content/we-retail/us/(.*).html$ $1.html [R,L]
#Map the root folder to the home page
RewriteRule ^/?$ en.html [R,L]
</IfModule>
 
The root path does resolve to en.html but it gives a 404 error instead of the internal redirect happening.
Is some additional configuration required for getting this working as expected?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Affirm 25
Level 5
Bimmi_Soi
Level 5

Likes

73 likes

Total Posts

81 posts

Correct reply

26 solutions
Top badges earned
Affirm 25
Contributor
Applaud 5
Boost 50
Ignite 1
View profile

Avatar
Affirm 25
Level 5
Bimmi_Soi
Level 5

Likes

73 likes

Total Posts

81 posts

Correct reply

26 solutions
Top badges earned
Affirm 25
Contributor
Applaud 5
Boost 50
Ignite 1
View profile
Bimmi_Soi
Level 5

22-06-2021

Here with the rewrite rule RewriteRule ^/?$ en.html  you have achieved the redirection on only dispatcher now there is one step which is left i.e. on publish environment you need to  go to /system/console/configMgr and open Apache Sling Resource Resolver Factory(org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl) and add in URL Mapping /content/we-retail/us/:/. Do not remove the already existing entry /:/ add after that. This is needed so that internally page can be  mapped to correct resource.

Answers (2)

Answers (2)

Avatar

Avatar
Affirm 100
MVP
shelly-goel
MVP

Likes

246 likes

Total Posts

410 posts

Correct reply

105 solutions
Top badges earned
Affirm 100
Give Back 25
Ignite 3
Give Back 10
Validate 1
View profile

Avatar
Affirm 100
MVP
shelly-goel
MVP

Likes

246 likes

Total Posts

410 posts

Correct reply

105 solutions
Top badges earned
Affirm 100
Give Back 25
Ignite 3
Give Back 10
Validate 1
View profile
shelly-goel
MVP

20-06-2021

@binoyp6992037  You can either use sling mappings or configure Apache Sling Resource Resolver Factory for internal redirect to work

https://www.aemquickstart.in/2019/01/url-shortening-in-aem.html

Avatar

Avatar
Boost 3
Level 1
soibimmi
Level 1

Likes

4 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Boost 3
Boost 1
View profile

Avatar
Boost 3
Level 1
soibimmi
Level 1

Likes

4 likes

Total Posts

3 posts

Correct reply

0 solutions
Top badges earned
Boost 3
Boost 1
View profile
soibimmi
Level 1

22-06-2021

-