Expand my Community achievements bar.

Nomination window for the Adobe Community Advisor Program, Class of 2025, is now open!
SOLVED

URL selector preventing 301 redirect

Avatar

Community Advisor

Hello,
I have set the Redirect path from page properties,

Sady_Rifat_0-1737103995887.png

So, once I hit the page: http://localhost:4503/content/we-retail/us/en/about-us.html 
it properly redirects me to the https://www.google.com/ 

But the issue is when I added a selector with URL, http://localhost:4503/content/we-retail/us/en/about-us.test.html
it instead of a 301 redirect, it shows me the actual About Us page. 

 

How to make it work, when I have any selector with the URL.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

The dispatcher-related solutions won't work for me because my use case is dealing with lot of pages and not a static pattern.
Now, for redirect, I wrote Cloudflare worker and it will be synced periodically with AEM.

View solution in original post

7 Replies

Avatar

Community Advisor

Hi @Sady_Rifat ,

Not sure about your use case but if list is limited and redirection are fixed we can redirect from dispatcher itself. Also it will help to off load the publish instance.

 

RewriteRule ^/contactus https://corp.exampleco.com/contactus.html [NC,R=301]

 

I have seen hard coded redirect for legacy Urls from dispatcher to maintain seo.

Thanks

Avatar

Community Advisor

No, the redirection is not fixed, also in the real case, all my requests have a selector that contains the Country code from the cookie with the URL.

Avatar

Community Advisor

Hi @Sady_Rifat 

Vanity URLs or Redirect URLs in page properties are best suited for simple, static redirections and should not be relied on for complex scenarios involving selectors.

Solution:

Dispatcher Rewrite Rules: Update Apache rules to include selectors. Example:

RewriteCond %{REQUEST_URI} ^/content/page\.selector\.html$
RewriteRule ^(.*)$ /new-path [R=301,L]

Sling Mappings: Add mappings in /etc/map to handle selectors in AEM.

ACS Commons Redirect Manager: Use this tool to manage redirects involving selectors via a UI.

Regards,

Shiv Prakash

Avatar

Community Advisor

In reality, all my requests have a selector containing the country code from the cookie with the URL.
So, in my understanding the default Redirection will be helpful for my case.

Avatar

Level 5

By default all selectors are denied in dispatcher filter, unless specified.

If you do not want this selector called "test", deny it in filter. If you do not want selectors for this page, deny selector for this page.

Avatar

Level 7

To fix the redirect issue with selectors:

  1. Check Page Properties: Ensure the redirect path includes URLs with selectors.
  2. Use Sling Rewrite: Configure a rewrite rule to handle redirects with selectors.
  3. Custom Servlet: Implement a custom Sling servlet to handle redirects programmatically for selector-based URLs.
  4. Dispatcher Rules: Verify dispatcher rules allow selector-based redirects.

These steps will ensure proper 301 redirects even with selectors in the URL.

Avatar

Correct answer by
Community Advisor

The dispatcher-related solutions won't work for me because my use case is dealing with lot of pages and not a static pattern.
Now, for redirect, I wrote Cloudflare worker and it will be synced periodically with AEM.