Redirection

Error with Redirection

You may have this kind of error with Redirection :

Fatal error: Can’t use function return value in write context in /wp-content/plugins/redirection/redirection-admin.php on line 390

Or :

Failed to perform query “ALTER TABLE wp_redirection_404 ADD INDEX ip (ip)”

Message: Failed to perform query “ALTER TABLE wp_redirection_404 ADD INDEX ip (ip)”
Installed: 2.3.3
Next: 2.4
Debug:

Duplicate key name ‘ip’
CREATE TABLE wp_redirection_items (
id int(11) unsigned NOT NULL AUTO_INCREMENT,
url mediumtext NOT NULL,
regex int(11) unsigned NOT NULL DEFAULT ‘0’,
position int(11) unsigned NOT NULL DEFAULT ‘0’,
last_count int(10) unsigned NOT NULL DEFAULT ‘0’,
last_access datetime NOT NULL,
group_id int(11) NOT NULL DEFAULT ‘0’,
status enum(‘enabled’,’disabled’) NOT NULL DEFAULT ‘enabled’,
action_type varchar(20) NOT NULL,
action_code int(11) unsigned NOT NULL,
action_data mediumtext,
match_type varchar(20) NOT NULL,
title varchar(50) DEFAULT NULL,
PRIMARY KEY (id),
KEY url (url(200)),
KEY status (status),
KEY regex (regex),
KEY group_idpos (group_id,position),
KEY group (group_id)
) ENGINE=MyISAM AUTO_INCREMENT=20 DEFAULT CHARSET=latin1

CREATE TABLE wp_redirection_groups (
id int(11) NOT NULL AUTO_INCREMENT,
name varchar(50) NOT NULL,
tracking int(11) NOT NULL DEFAULT ‘1’,
module_id int(11) unsigned NOT NULL DEFAULT ‘0’,
status enum(‘enabled’,’disabled’) NOT NULL DEFAULT ‘enabled’,
position int(11) unsigned NOT NULL DEFAULT ‘0’,
PRIMARY KEY (id),
KEY module_id (module_id),
KEY status (status)
) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1

CREATE TABLE wp_redirection_logs (
id int(11) unsigned NOT NULL AUTO_INCREMENT,
created datetime NOT NULL,
url mediumtext NOT NULL,
sent_to mediumtext,
agent mediumtext NOT NULL,
referrer mediumtext,
redirection_id int(11) unsigned DEFAULT NULL,
ip varchar(45) DEFAULT NULL,
module_id int(11) unsigned NOT NULL,
group_id int(11) unsigned DEFAULT NULL,
PRIMARY KEY (id),
KEY created (created),
KEY redirection_id (redirection_id),
KEY ip (ip),
KEY group_id (group_id),
KEY module_id (module_id)
) ENGINE=MyISAM AUTO_INCREMENT=3508 DEFAULT CHARSET=latin1

CREATE TABLE wp_redirection_404 (
id int(11) unsigned NOT NULL AUTO_INCREMENT,
created datetime NOT NULL,
url varchar(255) NOT NULL DEFAULT ”,
agent varchar(255) DEFAULT NULL,
referrer varchar(255) DEFAULT NULL,
ip varchar(45) DEFAULT NULL,
PRIMARY KEY (id),
KEY created (created),
KEY url (url),
KEY ip (id),
KEY referrer (referrer)
) ENGINE=MyISAM AUTO_INCREMENT=320043 DEFAULT CHARSET=utf8

Or :

WordPress database error: [Unknown column 'match_url' in 'where clause']
SELECT * FROM wp_redirection_items WHERE match_url='/' OR match_url='regex'

Or :

Fatal error: require_once(): Failed opening required (include_path=) in /wp-content/plugins/redirection/redirection.php on line 47

Or :

PHP Fatal error:  Uncaught Error: Class "WP_CLI" not found in /wp-content/plugins/redirection/redirection-cli.php:297
Stack trace:
#0 /wp-content/plugins/redirection/redirection.php(96): require_once()
#1 /wp-settings.php(388): include_once()
#2 phar:///...wp-cli/wp-cli/php/WP_CLI/Runner.php(1237): require()
#3 phar:///php/WP_CLI/Runner.php(1158): WP_CLI\Runner->load_wordpress()
#4 phar:///wp-cli.phar/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(23): WP_CLI\Runner->start()
#5 phar:///wp-cli/wp-cli/php/bootstrap.php(74): WP_CLI\Bootstrap\LaunchRunner->process(Object(WP_CLI\Bootstrap\BootstrapState))
#6 phar:///wp-cli/wp-cli/php/wp-cli.php(27): WP_CLI\bootstrap()
#7 phar:///php/boot-phar.php(11): include('phar:///Applica...')
#8 /wp-cli/wp-cli.phar(4): include('phar:///Applica...')
#9 {main}
  thrown in /wp-content/plugins/redirection/redirection-cli.php on line 297

There are multiple solutions to try to make it work.

Updates

The first thing to do if you are stuck with Redirection is to ensure that all your WordPress is up to date. You should check your :

  • WordPress
  • Plugins
  • Theme

Once all these updates are done, check back if these errors appear.

Check Redirection

Sometimes, you just need to disable the plugin, and enable it just after to make it work again.

If it doesn’t work, your Redirection plugin may be corrupted. To ensure that it’s not your case, you have to re-download the plugin (or the theme delivered with the plugin) and try to install it again.

Check others plugins

Are you sure that the error is related to Redirection? Maybe not.

It could be related to another plugin that is not compatible. It could happen when you use a cache plugin, a security plugin, or simply a poorly developed plugin.

Disable all plugins. Then, check for your error, if the error is still there, the problem is not related to plugins compatibility. If there are no more errors, then enable every plugin one by one and check for the error. The goal is to target the plugin involved.

Try another theme

The error can be a problem with your theme.

If it’s not already done, then you should install & activate the default WordPress theme like Twenty Twenty-Two. Check for the error, and see what is happening to be sure that your WordPress theme is not the cause.

Permalinks & htaccess

If it doesn’t work, you may have a problem with your WordPress permalinks and/or your htaccess file. You should go on your WordPress dashboard, and re-saving permalinks from the permalinks page.

Contact the developer

If all these solutions don’t work, we advise you to contact the plugin developer.

You may have found a new bug, or a specific issue. You should get in touch with the developer either on the WordPress plugin forum, either by mail, either on their specific website with their own support.

Alternative solutions

If the developer doesn’t reply, or your problem is very urgent, then you should try an alternative to the plugin.

There are thousands of plugins on the official directory, and many others outside. You should try to find and test them!

If the issue is very specific, and the plugin could not be replaced, we advise you to contact an expert.
This is the best way to ensure you're not going to break your site anymore.