The redirect manager handles 301/302/307 HTTP redirects, auto-creates redirects when a published post’s slug changes, and tracks 404 errors. PRO feature.
Database Table Schema
sql
CREATE TABLE wp_seoforge_redirects (
id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
source_url varchar(500) NOT NULL,
target_url varchar(500) NOT NULL DEFAULT '',
redirect_type int(3) NOT NULL DEFAULT 301,
hits int(11) NOT NULL DEFAULT 0,
last_hit datetime DEFAULT NULL,
auto_created tinyint(1) NOT NULL DEFAULT 0,
created_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
UNIQUE KEY source_url (source_url(191)),
KEY redirect_type (redirect_type)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;Programmatic Redirect Management
php
$redirects = SEOFORGE_Redirects::instance();
// Add a 301 permanent redirect
$id = $redirects->add( 'old-page', 'https://example.com/new-page/', 301, false );
// Add a 302 temporary redirect
$id = $redirects->add( 'promo-2023', 'https://example.com/promo-2024/', 302, false );
// Get all redirects as an array of objects
$all = $redirects->get_all();
// Get the 404 log
$log = $redirects->get_404_log();
// Returns: [ 'old-page' => 5, 'missing-post' => 2, ... ]Custom Redirect Rules
php
// Auto-create redirects from 404 log for high-traffic URLs
$log = SEOFORGE_Redirects::instance()->get_404_log();
foreach ( $log as $url => $hits ) {
if ( $hits >= 5 ) {
SEOFORGE_Redirects::instance()->add( $url, home_url( '/' ), 301, false );
}
}
// Delete all auto-created redirects
global $wpdb;
$wpdb->delete(
$wpdb->prefix . 'seoforge_redirects',
[ 'auto_created' => 1 ],
[ '%d' ]
);
// Query high-traffic redirects
$high_traffic = $wpdb->get_results(
$wpdb->prepare(
"SELECT * FROM {$wpdb->prefix}seoforge_redirects WHERE hits > %d ORDER BY hits DESC LIMIT %d",
100, 20
)
);404 Tracking
On every 404 page load, the request path is logged to a transient (seoforge_404_log) with hit counts. The log retains the top 50 URLs for one week.
—