A powerful and flexible redirect management module for Magnolia DXP, evolved from IBM iX's magkit-vanityurl. This module provides comprehensive URL redirect capabilities with an intuitive admin interface, pattern matching, multi-site support, and seamless integration with Magnolia's content management system.
- 301 & 302 Redirects: Support for permanent and temporary HTTP redirects
- Server-side Forwards: Internal request forwarding without client-side redirects
- Pattern Matching: Advanced wildcard and regex pattern support with parameter substitution
- Multi-site Support: Site-specific redirects with automatic fallback mechanisms
- Exclusion Patterns: Filter out unwanted patterns from redirect processing
- Backward Compatibility: Supports both legacy (
toUri,fromUri) and modern (targetUrl,sourceUrl) field naming - Headless Support: Dedicated URI mapping for headless CMS implementations
- Localization: Full i18n support (currently EN/DE)
- Public URL Service: Extensible service layer for custom URL resolution strategies
- Preview Support: Test redirects before publishing
- Magnolia DXP 6.4+ (for Magnolia 6.2.x, use version 1.2.0)
- Java 17 or higher
- Maven 3.6+
- Tomcat 10+ (Jakarta EE 10)
Add the following dependency to your Magnolia bundle:
<dependency>
<groupId>work.noice</groupId>
<artifactId>easyredirects</artifactId>
<version>2.0.0</version>
</dependency>Note for Magnolia 6.2.x users: Use version 1.2.0 which supports Magnolia 6.2.x with Java 11+ and Tomcat 9.
- Add the dependency to your project
- Start Magnolia - the module will be automatically installed
- Access the Redirects app from the Magnolia AdminCentral
The module works out of the box with sensible defaults. Redirects are stored in the redirects workspace.
The module automatically registers URI mappings in the following order:
/modules/easyredirects/virtualUriMappings/default- Standard redirects/modules/easyredirects/virtualUriMappings/headless- Headless-specific redirects
Configure the public URL service in your site definition:
/modules/multisite/config/sites/[your-site]:
publicUrlService:
class: work.noice.easyredirects.service.EasyRedirectsPublicUrlService- Open the Redirects app in Magnolia AdminCentral
- Click Add redirect
- Fill in the required fields:
- Source URL: The URL pattern to redirect from (supports wildcards)
- Target URL: The destination URL
- Type: Choose between 301 (permanent) or 302 (temporary)
- Site: Select target site (optional, defaults to all sites)
- Active: Enable/disable the redirect
The module supports advanced pattern matching:
/old-products/* → /products/*
/blog/*/comments → /blog/*/discussion
/product-(\d+) → /products/$1
/category/(.*)/page-(\d+) → /categories/$1?page=$2
Define patterns to exclude from redirect processing in the dialog:
.*/\.resources/.*- Exclude resource URLs.*\.(jpg|png|gif|css|js)$- Exclude static assets
- Use the Preview action in the Redirects app
- The preview popup shows:
-
Redirect type and status
-
Direct link to test the redirect
-
@Inject
private RedirectService redirectService;
public void createRedirect() {
Redirect redirect = new Redirect();
redirect.setSourceUrl("/old-path");
redirect.setTargetUrl("/new-path");
redirect.setType(RedirectType.PERMANENT_301);
redirect.setSite("my-site");
redirectService.save(redirect);
}Extend the base service for custom URL resolution:
public class CustomPublicUrlService extends SimplePublicUrlService {
@Override
public String createTargetUrl(Node node, String path) {
// Custom URL generation logic
return super.createTargetUrl(node, path);
}
}- RedirectsUriMapping: Core virtual URI mapping implementation
- RedirectService: Business logic for redirect management
- SimplePublicUrlService: Default implementation of public URL service
- RedirectsHeadlessUriMapping: Specialized mapping for headless setups
- Redirect: Core domain model
- RedirectRepository: Data access layer
- Custom
PublicUrlServiceimplementations - Additional virtual URI mappings
- Custom redirect validators
- Alternative storage backends
git clone https://github.com/noicework/easyredirects.git
cd easyredirects
mvn clean installmvn testContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Based on the original magkit-vanityurl module by IBM iX. Enhanced and maintained by the Magnolia community.
For issues, questions, or contributions, please use the GitHub issue tracker.