Rewrite Rules in AEM Dispatcher are not working for AEM - React SPA

Avatar

Avatar
Validate 1
Level 2
papenaarun
Level 2

Likes

8 likes

Total Posts

18 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Validate 1
Level 2
papenaarun
Level 2

Likes

8 likes

Total Posts

18 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
papenaarun
Level 2

20-04-2021

We are using AEM - React as a SPA.
The Rewrite Rules which are configured for URL shortening were not working with this AEM-React SPA.

We have made some changes in HierarchyPageImpl class so that :path will be specific to the short URL. And the changes are working fine.

But, we have a new use case where we a URL for which there will be different values for a query param. And based on that I need to load a specific page.
Ex:

When users access the below URLs, I need to check the param value and rewrite the rule based on that.

I am able to load those pages but the content for them is still on https://domain/abc page.

https://domain/abc?page=page1

https://domain/abc?page=page2


Below are the Rules I have configured:

RewriteCond %{REQUEST_URI} ^\/abc [NC]
RewriteCond %{QUERY_STRING} ^page=page1 [NC]
RewriteRule ^/(.*)$ /content/page1.html [L,PT]

 

RewriteCond %{REQUEST_URI} ^\/abc [NC]
RewriteCond %{QUERY_STRING} ^page=page2 [NC]
RewriteRule ^/(.*)$ /content/page2.html [L,PT]




I am not able to figure out how this can be handled.

 

Replies

Avatar

Avatar
Validate 1
Level 2
papenaarun
Level 2

Likes

8 likes

Total Posts

18 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Validate 1
Level 2
papenaarun
Level 2

Likes

8 likes

Total Posts

18 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
papenaarun
Level 2

20-04-2021

Yes, I have made the change as you suggested.
Also, when I access /page1 then page1.model.json is getting called, and the same for page2.


Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,462 likes

Total Posts

3,328 posts

Correct reply

949 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,462 likes

Total Posts

3,328 posts

Correct reply

949 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

20-04-2021

Hi,

I think your rules look fine, it just SPA app is not able to find out the pass-through link instead using the original requested link. TEST RESULT

Avatar

Avatar
Validate 1
Level 2
papenaarun
Level 2

Likes

8 likes

Total Posts

18 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Validate 1
Level 2
papenaarun
Level 2

Likes

8 likes

Total Posts

18 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
papenaarun
Level 2

20-04-2021

Yes. For SPA entire page content is based on <pagename>model.json. And this will called internally from clientlib-react. While rewriting the URL in dispatcher page will be loaded but the model.json will be of the page which we are accessing from the browser.

Avatar

Avatar
Boost 250
MVP
Nikhil-Kumar
MVP

Likes

251 likes

Total Posts

262 posts

Correct reply

38 solutions
Top badges earned
Boost 250
Validate 1
Ignite 3
Ignite 1
Give Back 5
View profile

Avatar
Boost 250
MVP
Nikhil-Kumar
MVP

Likes

251 likes

Total Posts

262 posts

Correct reply

38 solutions
Top badges earned
Boost 250
Validate 1
Ignite 3
Ignite 1
Give Back 5
View profile
Nikhil-Kumar
MVP

21-04-2021

@papenaarun - As per my experience with AEM SPA, you need to have one more rewrite rule for model.json as well.

Thanks,
Nikhil Kumar

Avatar

Avatar
Validate 1
Level 2
papenaarun
Level 2

Likes

8 likes

Total Posts

18 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile

Avatar
Validate 1
Level 2
papenaarun
Level 2

Likes

8 likes

Total Posts

18 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 5
Give Back 3
Give Back 10
View profile
papenaarun
Level 2

21-04-2021

Yes, but how do we know which page model.json has to load?

Because I will be receiving the request as abc.model.json