Introduction: What Are Redirects in Frappe?
In Frappe Framework v15, Redirects allow developers and administrators to forward visitors from one URL to another automatically. This feature is essential when pages are renamed, removed, or restructured, ensuring users and search engines always reach valid destinations.
What Is a Redirect in Frappe?
Answer:
A redirect in Frappe is a rule that maps an old URL path to a new destination path or external link.
When a user accesses the original URL, Frappe automatically sends them to the configured target page without manual intervention.
How Redirects Work in Frappe v15
Frappe processes redirects at the website routing layer.
The system:
- Intercepts incoming requests
- Matches the requested URL
- Checks the Redirect configuration
- Resolves the destination path
- Sends the browser to the new URL
This process happens before page rendering, ensuring fast redirection.
Core Components of Redirects
1. Source Path
The source path is the original URL that needs redirection.
Example:
/old-page
Visitors accessing this path will be redirected.
2. Target Path
The target path is the destination URL.
It can be:
- Another internal page
- A portal route
- An external website
Example:
/new-page
https://example.com
3. Redirect Type
Frappe supports HTTP redirect status codes:
- 301 – Permanent Redirect
- 302 – Temporary Redirect
301 redirects are recommended for permanent URL changes.
How to Create Redirects in Frappe v15
Step-by-Step Configuration
- Log in to Desk
- Open Website > Redirect
- Click New
- Enter Source Path
- Enter Target Path
- Select Redirect Type
- Save the record
The redirect becomes active immediately.
Using Redirect DocType
Frappe manages redirects through the built-in Redirect DocType.
Key fields include:
| Field | Purpose |
| Source Path | Original URL |
| Target Path | Destination URL |
| Redirect Type | HTTP status code |
| Disabled | Enable/disable rule |
This DocType allows centralized management.
Managing Bulk Redirects
For large migrations, redirects can be added using:
- Data Import Tool
- CSV Upload
- Custom Scripts
- Fixtures
This is useful during website restructuring.
Programmatic Redirect Handling
Server-Side Redirection
Developers can also perform redirects using Python:
frappe.local.response["type"] = "redirect"
frappe.local.response["location"] = "/new-page"
This is useful in controllers and APIs.
Client-Side Redirection
JavaScript-based redirection can be used for UI workflows:
window.location.href = "/dashboard";
Common Use Cases
Redirects are useful for:
- Page renaming
- Content restructuring
- Domain changes
- Landing page campaigns
- Removing outdated content
They preserve usability and rankings.
Real-World Example: Website Migration
Scenario:
A company migrates from:
/products-old
To:
/products
Redirect rule:
| Source | Target | Type |
| /products-old | /products | 301 |
All traffic is preserved after migration.
Best Practices for Redirect Management
- Maintain a redirect register
- Use descriptive routes
- Avoid circular redirects
- Test after deployment
- Monitor broken links
These practices ensure stability.
Advanced Redirect Configuration
Conditional Redirects
Using custom scripts, redirects can be applied based on:
- User role
- Country
- Language
- Login status
This enables personalized routing.
Redirect Chains Optimization
Avoid patterns like:
/a → /b → /c
Instead, redirect directly:
/a → /c
This improves performance.
Integration with Website Routing
Redirects integrate with:
- Page routes
- Generators
- Portal pages
- Web Forms
- Custom controllers
They function as part of the routing layer.
Troubleshooting Redirect Issues
Redirect Not Working
Check:
- Source path spelling
- Leading slashes
- Disabled status
- Cache refresh
Infinite Redirect Loop
Occurs when:
- Source and target point to each other
- Multiple conflicting rules exist
Industry Relevance
- Redirects are critical for:
- SaaS platforms
- ERP portals
- B2B websites
- E-commerce portals
- Knowledge platforms
They support long-term digital stability.
Cross-References
Official Documentation
https://docs.frappe.io/framework/user/en/guides/portal-development/redirects
Website Routing
https://docs.frappe.io/framework/user/en/guides/portal-development
Frappe v15 Source
https://github.com/frappe/frappe/tree/version-15
Conclusion
Redirects in Frappe Framework v15 provide a reliable way to manage URL changes, , and maintain seamless navigation. Using the built-in Redirect DocType and proper configuration practices, organizations can safely evolve their websites without losing traffic or usability.
When implemented strategically, redirects become a foundational component of professional ERPNext and Frappe portals.