Support » Plugin: Redirection » [Plugin Redirection] Sorry, but your redirection was not created

Viewing 15 replies - 16 through 30 (of 44 total)
  • Hi Wil,

    We investigated the wordpress user. It has full permissions for the entire database, which presumably includes wp_redirection_*. We couldn’t find any evidence of unique table-level permissions.

    Any thoughts?

    I’ll be more than happy to give the developers temporary access to my server if it will help debug. Having to manually add the entries in SQL is getting old



    Hi All

    It’s a real shame to see people still having a problem with this plugin.

    It seems to be working on my live WP install. I can add redirections through the dashboard without having to touch the DB.

    I’m wondering what the difference is between the systems.

    Here’s the SQL dump of my wp_redirection_items table structure for you all to compare.

    -- Table structure for table 'wp_redirection_items'
    CREATE TABLE IF NOT EXISTS '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')

    I’m running WP 3.1 on Apache and v2.2.3 of the plugin.
    For the plugin modules, I have WordPress, Apache and 404 Errors and I’m using the native WordPress module to handle the redirects (i.e. not .htaccess).

    Hope this helps a little.




    Done a little more code digging for you all.

    For the plugin /modules/redirect.php file, starting on line 168 my create fuction looks like this:

    function create ($details)
    		global $wpdb;
    		// Auto generate URLs
    		if ($details['source'] == '')
    			$details['source'] = Red_Item::auto_generate ();
    		if ($details['target'] == '')
    			$details['target'] = Red_Item::auto_generate ();
    		// Make sure we don't redirect to ourself
    		if ($details['source'] == $details['target'])
    			$details['target'] .= '-1';
    		$matcher = Red_Match::create ($details['match']);
    		$group_id  = intval ($details['group']);
    		if ($group_id > 0 && $matcher)
    			$match    = $wpdb->escape ($details['match']);
    			$regex    = (isset ($details['regex']) && $details['regex'] != false) ? true : false;
    			$url      = $wpdb->escape (Red_Item::sanitize_url ($details['source'], $regex));
    			$action   = $details['red_action'];
    			$position = $wpdb->get_var ("SELECT COUNT(id) FROM {$wpdb->prefix}redirection_items WHERE group_id='{$group_id}'");
    			$data = $wpdb->escape ($matcher->data ($details));
    			if ($action == 'url' || $action == 'random')
    				$action_code = 301;
    			else if ($action == 'error')
    				$action_code = 404;
    				$action_code = 0;
    			if (isset ($details['action_code']))
    				$action_code = intval ($details['action_code']);
    			// Quick check for loop
    //			if ($wpdb->get_var ("SELECT COUNT(id) FROM {$wpdb->prefix}redirection_items WHERE url='$url'") == 0)
    				$wpdb->query ("INSERT INTO {$wpdb->prefix}redirection_items (url,action_type,regex,position,match_type,action_data,action_code,last_access,group_id) VALUES ('$url','$action','".($regex ? 1 : 0)."','$position','$match','$data',$action_code,0,'$group_id')");
    				$group = Red_Group::get ($group_id);
    				Red_Module::flush ($group->module_id);
    				return Red_Item::get_by_id ($wpdb->insert_id);

    I’ve commented out three lines from the original plugin. This if statement checks for a loop in the redirection. Commented out just to help debugging.

    Make sure that in the dashboard the plugin “Groups” is showing at least one group for the WordPress module. I have two groups here “Redirection” and “Modified Posts”.

    When creating a new rule, the above code inserts the new rule into the DB wp_redirection_items table with a reference to which group it belongs to, in my case “Redirections”.

    The “Redirections” group is stored in another DB table wp_redirection_groups. The code above checks for and grabs the group ID, using it in the insert query.

    If you are using the WordPress plugin module to handle redirections, make sure that under the groups option there is at least one group showing there.

    Hope this helps.



    @bhelms I’d be happy to have a quick look through your wordpress redirection setup and see if I can get it working for you.

    You can contact me through my website on my member profile.


    @will I don’t see a website listed on your member profile.

    I asked my friend to look into this issue. He fixed it! Here is what he told me. (This is all greek to me, but hopefully it helps you guys.)

    I started logging queries and could see that they were being called, but no rows were being added to the table. First query I saw was:

    INSERT INTO wp_redirection_items (url,action_type,regex,position,match_type,action_data,action_code,last_access,group_id) VALUES (‘/about-us.html’,’url’,”,’23’,’url’,’/products.html’,’301′,’0′,’3′)

    But it errored with “Incorrect integer value: ” for column ‘regex’ at row 1″

    Obviously, the code should not be passing an empty string (”) as the value for an integer column, so I modified a line in wp-content\plugins\redirection\models\redirect.php as follows:

    Original: ‘regex’ => $regex
    New: ‘regex’ => ($regex ? 1 : 0)

    Tried to add the redirect again, and saw this query:

    INSERT INTO wp_redirection_items (url,action_type,regex,position,match_type,action_data,action_code,last_access,group_id) VALUES (‘/products.html’,’url’,’0′,’0′,’url’,’/test.html’,’301′,’0′,’1′)

    So now I’m passing ‘0’ instead of ” for regex, but it errored again with “Incorrect datetime value: ‘0’ for column ‘last_access’ at row 1”

    So I modified a line in wp-content\plugins\redirection\models\redirect.php as follows:

    Original: ‘last_access’ => 0
    New: ‘last_access’ => ‘0000-00-00 00:00:00’

    Then it worked. The changes I made to redirect.php are two “hacks” for two bugs.





    @mmmmdave – great contrib to the thread thanks for posting.

    Hopefully that will solve your problem.

    I’m still wondering why my redirect.php works without the hack?


    @mmmmdave That worked like a champ! Thanks!

    I tried to make the changes identified above (bearing in mind I am a complete novice at this). I made the code changes as above and seems to get an error which has taken down my site.

    Now on any page it says

    “Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ‘)’ in C:\Inetpub\wwwroot\\wp-content\plugins\redirection\models\redirect.php on line 202”

    It’s OK! Managed to pull it back round…

    The fix you showed above did not have a comma at the end so when I copied and pasted the hack it broke with the commas.

    Original: ‘regex’ => $regex
    New: ‘regex’ => ($regex ? 1 : 0),

    Original: ‘last_access’ => 0
    New: ‘last_access’ => ‘0000-00-00 00:00:00’,

    Tried adding a redirect and worked perfect – tested the redirect and it

    Thanks to everyone for there help on this.


    This fix worked perfectly. Thanks for the fix!

    There is a similar problem with editing/updating a redirection.

    In models/redirect.php function Red_Item::update you must cast regex to an integer, i.e. “‘regex’ => (int)$this->regex” in the wpdb->update statement. It should look like this:

    $wpdb->update( $wpdb->prefix.'redirection_items', array( 'url' => $this->url, 'regex' => (int)$this->regex, 'action_code' => $this->action_code, 'action_data' => $data, 'group_id' => $this->group_id, 'title' => $this->title ), array( 'id' => $this->id ) );

    I’ve opened Ticket #1292 at the WordPress Plugins Trac system, reporting both problems.

Viewing 15 replies - 16 through 30 (of 44 total)
  • The topic ‘[Plugin Redirection] Sorry, but your redirection was not created’ is closed to new replies.