Redirect Plus
Versions
Current version
2.1.0 (2026022700)
2.1.0
Plugin type: Administration tools
Frankenstyle component name: tool_redirectplus
Version build number: 2026022700
Version release name: 2.1.0
Maturity: Stable
Supported Moodle versions: 4.4, 4.5, 5.0, 5.1
Repository URL (Git): https://github.com/gwizit/moodle-tool_redirectplus/
Repository branch:
Repository tag:
Issue/bug tracker URL: https://github.com/gwizit/moodle-tool_redirectplus/issues
Changelog
All notable changes to the Redirect Plus plugin will be documented in this file.
[2.1.0] - 2026-02-27
New Features
Redirect Toggle Switch
- Added inline toggle switch next to each redirect's status badge in the Custom Redirects tab
- Flipping the toggle enables/disables the redirect via AJAX without a page reload
- Status badge text and colour update dynamically to reflect the new state
- Created new external service
tool_redirectplus_toggle_redirectfor the AJAX endpoint - Toggle is disabled during the request to prevent double-clicks; reverts on failure
Moodle 5.2 Compatibility
External API Migration
- Migrated
check_404_urlandtoggle_redirectexternal services from legacy global classes (external_api,external_value, etc.) to thecore_external\*namespace introduced in Moodle 4.2 - Removed deprecated
require_once($CFG->libdir . '/externallib.php')from both external service files
Bootstrap 5 Migration
- Replaced all Bootstrap 4 CSS classes with Bootstrap 5 equivalents across templates, PHP output, and JavaScript:
badge-success/badge-secondary'text-bg-success/text-bg-secondarycustom-control custom-checkbox'form-check(withform-check-input/form-check-label)font-weight-bold'fw-boldml-*/mr-*'ms-*/me-*text-left/text-right'text-start/text-enddata-toggle'data-bs-togglebtn-block'd-block w-100form-row'row g-3form-controlon<select>'form-select
Version Requirements
- Bumped minimum Moodle version to 4.5 (
2024100700) to ensurecore_externalnamespace and Bootstrap 5 compatibility layer are available
Files Added
classes/external/toggle_redirect.php— new external service for toggling redirect status
Files Modified
classes/external/check_404_url.php— external API namespace migrationdb/services.php— registeredtoggle_redirectexternal serviceindex.php— toggle switch HTML in redirects table, cache key bump to v5amd/src/redirects_tab.js— AJAX toggle handler usingcore/ajaxamd/src/main.js— updateddata-bs-toggleselectoramd/src/edit_redirect_form.js— updatedrow g-3in dynamic HTMLamd/build/*.min.js— rebuilt all minified JStemplates/main.mustache—data-bs-toggleon tab linkstemplates/settings_tab.mustache— BS5 form and utility classestemplates/edit_redirect_form.mustache— BS5 form and utility classestemplates/donation_banner.mustache—text-endstyles.css— toggle switch component styleslang/en/tool_redirectplus.php— new strings for toggle featureversion.php— version 2026022700, release 2.1.0, requires Moodle 4.5
[2.0.3] - 2025-12-19
Security Hardening
XSS Prevention
- Fixed Stored XSS vulnerability in 404 Report tab (Referrer column)
- Added strict validation to prevent
javascript:URLs in all redirect fields (Source, Destination, Login/Logout, Language URLs) - Implemented
clean_paramwithPARAM_URLfor referrer display
Regex Injection Fix
- Fixed potential regex injection in redirect matching logic
- Now properly escaping special characters in source URLs while preserving
*wildcard functionality - Ensures literal matching for characters like
.,?,+
UI & Support
Support Links
- Added "Report an Issue" button to the donation banner in the plugin UI
- Updated donation links to new Square URL
- Updated README with direct links to GitHub issue tracker
[2.0.2] - 2025-11-13
External Audit Fixes
Moodle Plugin Review
- Addressed issues identified during external audit by Moodle developers
- Fixed code quality and compliance issues prior to production release
- Enhanced plugin standards compliance for Moodle plugins directory
[2.0.1] - 2025-11-07
Security & Internationalization Improvements
Security Enhancements
- Changed
PARAM_RAWtoPARAM_CLEANHTMLfor custom 404 message input (index.php) - Changed
PARAM_RAWtoPARAM_TEXTfor URL parameter in error404.php - Changed
PARAM_TEXTtoPARAM_URLfor redirect URL in settings - Added security comment for PARAM_RAW usage in external API return values
- Removed redundant
filter_var()validation (now handled by PARAM_URL) - All POST/GET parameters now properly validated with appropriate PARAM types
Internationalization
- Removed ALL hardcoded user-visible text from templates
- Added 11 new language strings for placeholders and test section text
- Updated
edit_redirect_form.mustacheto use language strings for placeholders - Updated
settings_tab.mustacheto use language strings for test section - Replaced hardcoded checkmark """ with FontAwesome icon in index.php
- All templates now fully support multi-language installations
Documentation Updates
- IMPORTANT: Added strong recommendation to use Apache/Nginx server configuration for 404 logging
- Added detailed warning about
.htaccessmethod limitations - Clarified that
.htaccessdoes NOT work with PHP-FPM or FastCGI - Updated README.md with comprehensive server configuration guidance
- Explained why server configuration access is highly recommended
- Added troubleshooting notes for 500 errors with
.htaccessmethod
Cache Management
- Incremented cache key version to v3 to invalidate old cached HTML
- Cache now uses FontAwesome icons instead of Unicode checkmarks
Version Bump
- Updated to v2.0.1 (2025110700)
- Major version increment due to security improvements
[1.8.1] - 2025-11-06
UI/UX Improvements
Tab Reordering and Welcome Message
- Reordered tabs: Settings (first), Custom Redirects (second), 404 Errors (third)
- Added welcome message to Settings tab explaining plugin functionality
- All dropdown sections now collapsed by default for cleaner interface
- Created new "Redirect Configuration" section for redirect-specific settings
- Moved "Disable redirect for administrators" to new Redirect Configuration section
- 404 Error Page Configuration section now collapsed by default
Donation Support
- Added donation banners to top and bottom of all tabs
- Created reusable donation banner template
- Link to support plugin development: https://square.link/u/C0Xn8NZw
Template Fixes
- Fixed mustache syntax errors with
{{#str}}helper and triple braces - Corrected mismatched tag delimiters in multiple templates
- Updated redirects_tab, settings_tab, and edit_redirect_form templates
Version History
[1.5.0] - 2025-11-03
Major Feature - Custom URL Redirects with Conditional Parameters
NEW: Redirect ANY page based on user conditions!
This release adds powerful custom redirect functionality that works for BOTH existing pages and 404 errors.
Features Added
Custom URL Redirects
- Create redirects for any URL (homepage
/,/faq/, or any path) - Works for existing pages AND 404 errors
- New "Custom Redirects" tab in admin interface
- Enable/disable individual redirects
- Full management UI (add, edit, delete)
- Create redirects for any URL (homepage
Conditional Parameters
- Login Status: Different URLs for logged-in users vs. guests
- User Language: Redirect based on browser language or Moodle preference
- Combined Conditions: Use both login and language together
- Parameters stored as flexible JSON for future expansion
Administrator Bypass
- New setting: "Disable redirect for administrators" (enabled by default)
- Admins bypass all custom redirects when signed in
- Perfect for testing and troubleshooting
Technical Implementation
- Proper Moodle Integration: Uses
tool_redirectplus_after_config()callback in lib.php - Works with All PHP Setups: PHP-FPM, FastCGI, mod_php - no special configuration needed
- Early Interception: Redirects happen before page rendering
- Database Schema: New
tool_redirectplus_redirectstable with JSON options field - Helper Functions: Complete API for redirect matching and evaluation
Example Use Cases
- Homepage language redirect: Send Spanish speakers to
/es/, French to/fr/ - Member area: Redirect logged-out users to login page
- FAQ for guests: Different FAQ pages for members vs. visitors
- Legacy URL redirects: Old pages to new locations with conditions
Database Changes
- New table:
tool_redirectplus_redirects - Fields: source_url, redirect_options (JSON), enabled, timestamps
- Indexes on source_url and enabled for performance
Files Added
edit_redirect.php- Add/edit redirect form with JavaScript UItemplates/redirects_tab.mustache- Redirects management interface- Extensive language strings for all new features
Upgrade Notes
- Database upgrade automatic on plugin update
disable_redirect_adminconfig set to 1 (enabled) by default- All existing functionality preserved
- No action required - works immediately after upgrade
Removed
- Old backup files (
index_backup.php,index_old.php) - Development zip files
- Unused hook callback approach (in favor of simpler after_config callback)
[1.3.0] - 2025-10-31
Changed - Enhanced Settings Interface
- Behavior Dropdown: Settings page now uses a dropdown to select between "Show custom message" or "Redirect to another page"
- Cleaner Interface: Removed blue info box and redundant descriptive text
- Dynamic Display: Only the relevant field (message editor or URL input) is shown based on selected behavior
- Better UX: Simplified workflow makes it clearer how to configure 404 handling
Improved
- Settings form now saves behavior preference in config
- JavaScript toggles between message and redirect sections dynamically
- More intuitive for administrators to configure
Technical
- AMD Modules: JavaScript moved to proper AMD module structure (amd/src and amd/build)
- Gruntfile: Added Gruntfile.js for automated minification with grunt
- Build Process: Use
npm installthengrunt amdto rebuild JavaScript from source - Package script updated to exclude node_modules and development files
[1.2.0] - 2025-10-30
CRITICAL FIX - URL Tracking Now Works!
Problem: URL tracking was failing with "Unknown URL" even with correct server configuration.
Solution: Changed approach to pass URL as query parameter instead of relying on server variables.
Changed - BREAKING (Requires Configuration Update)
- Apache Configuration: Now uses
ErrorDocument 404 /admin/tool/redirectplus/error404.php?url=%{REQUEST_URI} - Nginx Configuration: Now uses
error_page 404 /admin/tool/redirectplus/error404.php?url=$request_uri; - Simpler & More Reliable: URL is passed directly as a parameter, works on all server configurations
What You Need to Do:
- Update your .htaccess or Nginx config with the NEW configuration shown in the Setup Instructions tab
- The old configuration will show "Unknown URL" - you MUST update to the new format
- Test by visiting a non-existent page - it should now log the correct URL
Technical Details:
- URL now passed via
?url=query parameter - Falls back to server variables if parameter not present
- More reliable across different server configurations and hosting environments
- Works with Apache, Nginx, Plesk, and other control panels
[1.1.3] - 2025-10-30
Fixed
- Accordion Dropdowns: Fixed collapsible sections in Setup Instructions tab (Apache/Nginx/Plesk)
- Now uses Moodle's standard Bootstrap collapse functionality with jQuery
- Added visual indicators (-/-) that toggle when sections expand/collapse
- Apache section is open by default, others are collapsed
Improved
- Custom Message Editor: Significantly increased textarea height (400px minimum, 20 rows)
- Much better editing experience for longer custom messages
- TinyMCE editor has more vertical space
[1.1.2] - 2025-10-30
Fixed
- URL Detection Improved: Added multiple fallback methods to detect the original 404 URL
- Now checks: REDIRECT_URL, REDIRECT_REQUEST_URI, REQUEST_URI, REDIRECT_SCRIPT_URL, ORIGINAL_REQUEST_URI
- Better handling when server variables are not available
- Fixed settings form validation - redirect URL is now optional and not required
Added
- TinyMCE Editor: Custom message field now uses Moodle's built-in HTML editor
- Enhanced Apache Instructions: Added SetEnvIf directive to ensure URL is properly passed
- Troubleshooting Section: Added helpful troubleshooting info in Setup tab
- Better validation for redirect URL (validates format when provided)
Changed
- Changed redirect URL input from type="url" to type="text" to avoid browser validation issues
- Improved error messages and help text
- Apache configuration now includes two lines for better URL detection
[1.1.1] - 2025-10-30
Fixed
- Critical Bug: Fixed URL recording - now correctly logs the actual 404 URL instead of the error page itself
- Error page now properly reads REDIRECT_URL server variable set by Apache/Nginx
- Added fallback URL detection methods for various server configurations
Changed
- Simplified Settings: Removed confusing enable checkbox - tracking is always enabled
- Clearer Settings Logic: Custom message is now the default behavior with redirect as an optional alternative
- Redirect URL now takes priority over custom message when both are set
- Improved settings page layout and descriptions
- Added helpful notes in setup instructions about how URLs are passed by servers
Improved
- Better user experience in settings page
- Clearer language strings explaining the default behavior
- More informative setup instructions with server-specific notes
[1.1.0] - 2025-10-30
Major Changes
- New Architecture: Changed from automatic callback to server-configured custom 404 page
- Unified Interface: Combined report and settings into single page with tabbed navigation
- Better Admin Placement: Moved from Tools to General section in Site Administration
Added
- Custom 404 error page (
error404.php) that logs errors before displaying content - Settings tab with configuration options:
- Enable/disable 404 tracking
- Redirect to custom URL option
- Custom HTML message option
- Setup Instructions tab with:
- Server-specific configuration instructions (Apache, Nginx, Plesk)
- Test button to verify 404 tracking is working
- Copy-ready configuration snippets
- Tabbed interface for better organization
- Comprehensive server configuration documentation
Changed
- Removed
tool_redirectplus_after_http_headers()callback function - Main page now accessible from Site administration > Redirect Plus (General section)
- Updated all documentation to reflect new setup process
Technical Changes
- Plugin now requires server-level 404 error page configuration
- More reliable 404 detection (server-level vs PHP-level)
- Improved user experience with custom messages or redirects
- Better frankenstyle naming consistency
[1.0.0] - 2025-10-30
Added
- Initial release of Redirect Plus
- Automatic 404 error logging functionality
- Comprehensive 404 error report page with pagination
- Database table
tool_redirectplus_404for storing error records - Delete individual error records functionality
- Delete all error records functionality
- Privacy API implementation for GDPR compliance
- Logger class for managing 404 error records
- Full frankenstyle naming convention compliance
- Support for Moodle 4.3, 4.4, 4.5, 5.0, and 5.1
- User-friendly admin interface in Tools menu
- IP address tracking (IPv4 and IPv6 support)
- User agent tracking
- Referrer URL tracking
- User association with 404 errors
- Timestamp recording
- Comprehensive documentation (README.md and INSTALL.md)