We were adding multilingual sites for our website (project). The main requirement from the client was to include language code and country code (jp-ja, es-es, fr-fr, etc) in the urls of multi-language sites except for the English site.
Before that, let's see how the normal url redirection will happen in AEM.
Configuring an Internal Redirect from http://localhost:4503/content/myproject/abc.html to http://localhost:4503/abc.html:
Go to CRXDE and navigate to /etc/map/http
2. Create a new node of, type sling:Mapping and name localhost.4503
3. Click Save All
4. Add the following properties to the newly created node.
>Name sling:internalRedirect
>Type String[]
>Value /content/myproject
5. Click Save All
6. Then Navigate to /etc/map/http/localhost.4503
7. Create a new node of, type sling:Mapping and name redirect
8. Add the following properties to the node ‘redirect’.
>Name sling:internalRedirect
>Type String[]
>Value /$1, /content/myproject/$1.html
>Name sling:match
>Type String
>Value (.+)$
9. Then click Save All.
By this, requests such as http://localhost:4503/content/myproject/abc.html and
redirects to http://localhost:4503/abc.html.
*Note: Use ‘ . ‘ instead of ‘: ‘ while giving value. (eg.: localhost.4503).
Now, let's discuss our scenario.
Configuring an Internal Redirect from http://localhost:4503/content/myproject/en/home/abc.html to http://localhost:4503/abc.html and http://localhost:4503/content/myproject/fr-fr/home/abc.html to http://localhost:4503/fr-fr/abc.html.
In this case, the redirect url should show the country_code and language_code eg. (fr-fr) in the multilingual sites except for the English site.
- Go to CRXDE and navigate to /etc/map/http
- Create a new node of, type sling:Mapping and name localhost.4503
- Click Save All
- Add the following properties to the newly created node.
>Name sling:internalRedirect
>Type String[]
>Value /content/myproject/en/home/(.*)() , /content/myproject/([^/]+)/home(/.*)
second property,
>Name sling:match
>Type String
>Value localhost.4503/$1/$2
5. Click Save All
6. Then Navigate to /etc/map/http
7. Create a new node of, type sling:Mapping and name redirect_en
8. Add the following properties to the node ‘redirect_en’.
first property,
>Name sling:internalRedirect
>Type String[]
>Value /$1, /content/myproject/en/home/$1.html
second property,
>Name sling:match
>Type String
>Value localhost.4503/([^.]+)$
9. Create another node under /etc/map/http with,type sling:Mapping and name redirect_fr .
10. Add the following properties to ‘redirect_fr’
first property,
>Name sling:internalRedirect
>Type String[]
>Value /$1, /content/myproject/fr-fr/home/$1.html
second property
>Name sling:match
>Type String
>Value localhost.4503/fr-fr/([^.]+)$
11. Then click Save All.
Now, it will work!
No comments:
Post a Comment
If you have any doubts or questions, please let us know.