Hi,
We did the URL shortening for the site https://www.test.com/content/test/en_us/test.html
So the URL now is https://www.test.com/en_us/test.html but we are still able to access https://www.test.com/content/test/en_us/test.html is this expected behaviour or still we eradicate the /content path fully?
Thanks,
Nivetha Selvakumar
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @nivethaS ,
When you implement URL shortening in AEM, it is common to have the original long URLs still accessible. This is expected behavior as it ensures backward compatibility and avoids breaking existing links. However, for a more seamless user experience and to avoid duplicate content issues (which can affect SEO), it is generally advisable to enforce the shortened URLs and redirect the long ones to their shorter counterparts.
Here’s how you can fully eradicate the /content path and ensure users are only accessing the shortened URLs:
Create a Sling Mapping Configuration: Use the Apache Sling Resource Resolver Factory configuration to create a mapping rule. This will map the long URL to the short URL.
{
"/content/test/en_us/test.html": "/en_us/test.html"
}
Configure URL Rewriting Using URL Mapping: Create an etc/map configuration in AEM to handle URL mapping.
/etc
/map
/http
/test.com
- Under `/test.com`, create a node named `sling:Mapping` with the following properties:
- `sling:match = "/content/test/(.*)"`
- `sling:redirect = "/$1"`
Setup Apache Rewrite Rules: If you are using an Apache HTTP server as a front end to AEM, you can set up rewrite rules to ensure any access to the long URL is redirected to the short URL.
Add the following rewrite rules to your Apache configuration:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/content/test/
RewriteRule ^/content/test/(.*)$ /$1 [R=301,L]
This rule will redirect any request that matches /content/test/... to /....
Testing Redirects: Test the configurations by accessing the original long URL. It should automatically redirect to the shortened URL.
Check Logs and Monitoring: Monitor your AEM logs and web server logs to ensure that the redirections are working as expected and there are no issues.
By following these steps, you can ensure that users are always directed to the shortened URLs and the original long URLs are properly redirected, thereby eliminating access to the /content path.
Hi,
It depends on how you implement it. Can you provide more insights?
It depends on your usecase but it's generally recommended to keep the original URL accessible, as it can be useful for various purposes, such as:
Hi @nivethaS ,
When you implement URL shortening in AEM, it is common to have the original long URLs still accessible. This is expected behavior as it ensures backward compatibility and avoids breaking existing links. However, for a more seamless user experience and to avoid duplicate content issues (which can affect SEO), it is generally advisable to enforce the shortened URLs and redirect the long ones to their shorter counterparts.
Here’s how you can fully eradicate the /content path and ensure users are only accessing the shortened URLs:
Create a Sling Mapping Configuration: Use the Apache Sling Resource Resolver Factory configuration to create a mapping rule. This will map the long URL to the short URL.
{
"/content/test/en_us/test.html": "/en_us/test.html"
}
Configure URL Rewriting Using URL Mapping: Create an etc/map configuration in AEM to handle URL mapping.
/etc
/map
/http
/test.com
- Under `/test.com`, create a node named `sling:Mapping` with the following properties:
- `sling:match = "/content/test/(.*)"`
- `sling:redirect = "/$1"`
Setup Apache Rewrite Rules: If you are using an Apache HTTP server as a front end to AEM, you can set up rewrite rules to ensure any access to the long URL is redirected to the short URL.
Add the following rewrite rules to your Apache configuration:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/content/test/
RewriteRule ^/content/test/(.*)$ /$1 [R=301,L]
This rule will redirect any request that matches /content/test/... to /....
Testing Redirects: Test the configurations by accessing the original long URL. It should automatically redirect to the shortened URL.
Check Logs and Monitoring: Monitor your AEM logs and web server logs to ensure that the redirections are working as expected and there are no issues.
By following these steps, you can ensure that users are always directed to the shortened URLs and the original long URLs are properly redirected, thereby eliminating access to the /content path.
@nivethaS Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.
Views
Likes
Replies