Hi @anushaat ,
When users bookmark or directly hit a video page URL, and it causes a 404, you want to redirect all such requests to /home.html.
This requires:
- Apache Rewrite Rule in your Dispatcher configuration.
- Optionally, Angular route fallback (if routing is part of the issue).
Dispatcher (Apache) Rewrite Rule
1. Enable Rewrite Engine (if not already enabled)
RewriteEngine On
2. Add Rewrite Rule in dispatcher /conf.d/ (e.g., vhost or separate file)
Sample Rewrite Rule — Redirect all /videos/... URLs to /home.html
# Redirect all URLs under /videos/ to /home.html
RewriteCond %{REQUEST_URI} ^/videos/.*$ [NC]
RewriteRule ^/videos/.*$ /home.html [R=302,L]
3. For DAM URLs (e.g., /content/dam/training-videos/...), use this rule
# Redirect DAM video URLs to /home.html
RewriteCond %{REQUEST_URI} ^/content/dam/training-videos/.*$ [NC]
RewriteRule ^/content/dam/training-videos/.*$ /home.html [R=302,L]
4. If Angular is routing via hash-based URLs or SPA routing, and direct URL hits cause 404, redirect any unknown routes to /home.html:
# Redirect any unknown route (not a real AEM page) to /home.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/videos/.*$ /home.html [R=302,L]
To verify:
- Access /videos/any-video directly – should redirect to /home.html.
- Access /content/dam/training-videos/video.mp4 – should redirect.
- Use 302 for temporary testing; switch to 301 for permanent redirects after confirmation.
Angular Fallback (Only if Needed)
If Angular routes are causing 404s due to SPA routing:
Add this to angular.json → "baseHref": "/".
In index.html:
<base href="/">
Add catch-all route in Angular:
{ path: '**', redirectTo: '/home' }
Dispatcher Rule Example
RewriteEngine On
# Redirect all /videos/ URLs to /home.html
RewriteCond %{REQUEST_URI} ^/videos/.*$ [NC]
RewriteRule ^.*$ /home.html [R=302,L]
# Redirect all DAM video paths to /home.html
RewriteCond %{REQUEST_URI} ^/content/dam/training-videos/.*$ [NC]
RewriteRule ^.*$ /home.html [R=302,L]
Regards,
Amit