1
votes

I'm trying to do an internal redirect in AEM 6.3, what I'm trying to do is: any request coming to localhost:4502/aem should be redirected to localhost:4502/content/myapp/en/login.html. So I created a sling:mapping node under /etc/map/http/:

jcr:primaryType="sling:Mapping"  
sling:internalRedirect=/content/myapp/en/login.html -> Type String
sling:match=localhost.4502/aem -> Type String 

I'm getting an Internal Server Error: Cannot serve request to /aem on this server. But if I add the .html suffix (request to localhost:4502/aem.html it works and redirects correctly.

Also tried:

sling:match=localhost.4502/aem(.*)(/.*)?

I wonder what I'm missing/doing wrong. Thanks in advance for your help.

2
Your first example works for me. Have you tried to create this redirect for a different url like localhost:4503/mytest123? Maybe /aem is captured already somewhere else. You should also test it with a fresh plain AEM installation - just to exclude any interferences with your project. - Alexander Berndt
I am wondering why you are doing this? AEM authentication can be extended. So you might not need your "own" login page. And redirecting every request to /aem to your login page is also sub-optimal since this would also apply to users that are already logged in. - Jens
It is also working for me. - ruchika jain

2 Answers

0
votes

I solve it using sling:redirect instead of sling:internalRedirect, not sure if this is the proper solution, but is working:

jcr:primaryType="sling:Mapping"  
sling:redirect=localhost:4502/content/myapp/en/login.html -> Type String
sling:match=localhost.4502/aem -> Type String 

If you have a better option, feel free posting it, Thanks.

0
votes

I would recommend you go to http://localhost:4502/system/console/jcrresolver to check whether your redirects are correct or incorrect!

for example your CRXDE Internal URL is http://localhost:4502/content/app1/en-in/home.html and preferred external URL is http://localhost:4502/home/

There are to options you will be able to see

map: map returns you the external URL when you enter internal URL. Remember to add .html at the end.

resolve: resolve does the reverse of map. Remember to add .html at the end while testing.