A simple and powerful WordPress plugin for managing 301 redirects with CSV import/export functionality. Perfect for site migrations, URL restructuring, and SEO management.
- Simple Admin UI: Easy-to-use interface for managing redirects
- 301 Redirects: Proper permanent redirects for SEO
- CSV Import: Bulk import redirects from CSV files
- CSV Export: Export all redirects for backup or migration
- Fast Execution: Uses
template_redirecthook for early processing - URL Normalization: Handles both relative and absolute URLs
- Duplicate Detection: Prevents duplicate source URLs
- Search Functionality: Quick search through your redirects
- Click to Copy: Click any URL to copy it to clipboard
- Responsive Design: Mobile-friendly admin interface
- WPCS Compliant: Follows WordPress coding standards
- Upload the
yt-custom-redirect-managerfolder to the/wp-content/plugins/directory - Activate the plugin through the 'Plugins' menu in WordPress
- Go to Tools → Redirects to manage your redirects
- Add redirects manually or import from CSV
- Navigate to Tools → Redirects
- Fill in the "Add New Redirect" form:
- Source URL: The old URL to redirect from (e.g.,
/old-page) - Destination URL: The new URL to redirect to (e.g.,
/new-page)
- Source URL: The old URL to redirect from (e.g.,
- Click "Add Redirect"
Relative URLs (recommended):
Source: /old-page
Destination: /new-page
Absolute URLs:
Source: https://yoursite.com/old-page
Destination: https://yoursite.com/new-page
External URLs:
Source: /old-page
Destination: https://external-site.com/page
Mixed formats:
Source: /old-page
Destination: https://yoursite.com/new-page
- Prepare your CSV file with two columns:
sourceanddestination - Example CSV format:
source,destination /old-page-1,/new-page-1 /old-page-2,/new-page-2 /old-blog,/blog - Go to Tools → Redirects
- Click "Choose File" under Import/Export section
- Select your CSV file
- Click "Import CSV"
- Go to Tools → Redirects
- Click "Export CSV" button
- Save the downloaded file (
redirects-YYYY-MM-DD.csv) - Use this file for backup or migration to another site
- User visits a URL (e.g.,
/old-page) - Plugin checks if URL matches any source URLs
- If match found, redirects to destination URL (301 permanent)
- If no match, WordPress continues normal page loading
template_redirect hook (priority 1)
↓
Get current URL
↓
Normalize URL format
↓
Loop through redirects
↓
Match found? → wp_safe_redirect() with 301
↓
No match? → Continue to WordPress
The plugin normalizes URLs for consistent matching:
Input variations:
old-page→/old-page/old-page/→/old-pagehttps://site.com/old-page→/old-page
Normalized output:
- Leading slash added if missing
- Trailing slashes removed (except root
/) - Full URLs converted to paths for matching
-
Statistics
- Total number of active redirects
-
Import/Export
- CSV file upload for bulk import
- One-click export of all redirects
-
Add New Redirect
- Source URL field with validation
- Destination URL field with validation
- Auto-formatting of URLs
-
Current Redirects
- Table showing all active redirects
- Source and destination URLs
- 301 redirect type badge
- Delete button for each redirect
- Search functionality
- Click to copy URLs
yt-custom-redirect-manager/
├── class-yt-custom-redirect-manager.php # Main plugin file (~600 lines)
├── assets/
│ ├── css/
│ │ └── yt-crm-admin.css # Admin UI styles
│ └── js/
│ └── yt-crm-admin.js # Admin interactions
└── README.md # This file
All functions, classes, and elements use the yt_crm prefix:
- Class:
YT_Custom_Redirect_Manager - Constants:
YT_CUSTOM_REDIRECT_MANAGER_* - Functions:
yt_crm_* - CSS Classes:
.yt-crm-* - JavaScript Object:
ytCrmAdmin - Options:
yt_custom_redirect_manager_redirects - Text Domain:
yt-custom-redirect-manager
Redirects are stored as a single option:
- Option name:
yt_custom_redirect_manager_redirects - Format: Array of redirect objects
- Structure:
array( array( 'source' => '/old-page', 'destination' => '/new-page' ), // ... more redirects )
- Capability Checks: All admin actions require
manage_options - Nonce Verification: CSRF protection on all forms
- Input Sanitization: All inputs sanitized before storage
- Output Escaping: All output properly escaped
- File Upload Validation: CSV files validated before processing
- Safe Redirects: Uses
wp_safe_redirect()for security
- Early Execution: Runs on
template_redirect(priority 1) - Fast Matching: Simple array loop with normalized URLs
- No Database Queries: Redirects loaded once from options
- Cached in Object: Stored in class property for efficiency
- Minimal Overhead: Only processes on front-end, not admin
source,destination
/old-url-1,/new-url-1
/old-url-2,/new-url-2
/about-old,/about
The plugin exports in the same format:
- Header row:
source,destination - Each redirect as a row
- Properly escaped CSV format
- UTF-8 encoding
- Header row: First row can be header (will be skipped if detected)
- Two columns: Must have source and destination
- Empty rows: Skipped automatically
- Duplicates: Source URLs that already exist are skipped
- Validation: Empty source or destination are skipped
Moving from old domain to new domain:
source,destination
/,https://newdomain.com/
/about,https://newdomain.com/about
/contact,https://newdomain.com/contact
Changing URL structure:
source,destination
/blog/old-post,/articles/old-post
/products/item-1,/shop/item-1
/services/consulting,/consulting
Combining duplicate content:
source,destination
/old-category/post,/new-category/post
/archive/2020/post,/blog/post
/tag/old-tag,/category/new-category
Redirecting removed pages:
source,destination
/discontinued-product,/products
/old-service,/services
/expired-offer,/
- Check plugin activation: Ensure plugin is activated
- Clear cache: Clear any caching plugins or CDN cache
- Check URL format: Verify source URL matches exactly
- Test in incognito: Browser may cache redirects
- Check for conflicts: Disable other redirect plugins
- Check file format: Must be valid CSV with comma delimiter
- Check encoding: Should be UTF-8
- Verify structure: Two columns (source, destination)
- Check for errors: Look at WordPress admin notices
- File size: Very large files may timeout (split into smaller files)
If you create circular redirects:
/page-a → /page-b
/page-b → /page-a
This will cause infinite redirects. The plugin doesn't prevent this, so be careful!
The JavaScript validation prevents this, but if you import via CSV, the plugin will create the redirect. This is essentially a no-op.
- Test redirects: Always test after adding redirects
- Use relative URLs: Easier to migrate between environments
- Export regularly: Keep backups of your redirect rules
- Document changes: Keep notes on why redirects were created
- Clean up old redirects: Remove redirects for pages that no longer need them
- Use 301 for permanent: Plugin uses 301 (permanent) - appropriate for most cases
- Avoid redirect chains: Redirect directly to final destination
- 301 only: Only permanent redirects (not 302 temporary)
- Exact match: No wildcard or regex matching
- No conditions: Can't redirect based on user role, device, etc.
- No redirect history: Doesn't track redirect hits or statistics
- Single destination: Each source has one destination
- Analytics: No tracking of redirect usage
- Bulk edit: No bulk delete or edit functionality
- Redirect chains: No detection of redirect chains
- URL parameters: Query strings not preserved
- Complex patterns: No regex or wildcard support
When the plugin is deleted via WordPress admin:
- All redirects are removed from database
- Plugin option is deleted
- WordPress cache is flushed
- No traces left behind
- WordPress 5.8 or higher
- PHP 7.4 or higher
manage_optionscapability for admin access
- Main PHP File: ~600 lines (with comments)
- CSS File: ~165 lines
- JS File: ~215 lines
- Total: ~980 lines across all files
Yes! Just use the full URL in the destination field:
Source: /old-page
Destination: https://external-site.com/page
No, query strings are not automatically preserved. You need to include them in your redirect rules.
Yes, use / as the source URL:
Source: /
Destination: /new-home
There's no hard limit, but performance may degrade with thousands of redirects. For large-scale redirects, consider server-level solutions.
Yes! The plugin intercepts all URLs before WordPress routing, so it works with posts, pages, custom post types, and even non-existent URLs.
If you can export to CSV format from another plugin, you can import here. Just ensure the CSV has source and destination columns.
Not supported in this lite version. Each redirect is an exact match.
- Initial release
- 301 redirect functionality
- Admin UI for managing redirects
- CSV import functionality
- CSV export functionality
- URL normalization
- Duplicate detection
- Search functionality
- Click to copy URLs
- Mobile-responsive design
GPL v2 or later
Krasen Slavov
- Website: https://krasenslavov.com
- GitHub: https://github.com/krasenslavov
For issues and feature requests, please visit the GitHub repository.
Potential features for future versions:
- Redirect statistics and analytics
- 302 temporary redirects
- Wildcard matching
- Regex pattern support
- Bulk delete functionality
- Redirect chains detection
- Import from other plugins
- Conditional redirects (user role, device, etc.)
- Query string preservation
- Redirect testing tool