Just downloaded the vanilla 2.2.3 version.
Basic default out-of-the-box config.
Tried to put in a redirection /test to /test 2 and all I get is an error message "Sorry, but your redirection was not created"
No redirection rules entered.
Wil.
Just downloaded the vanilla 2.2.3 version.
Basic default out-of-the-box config.
Tried to put in a redirection /test to /test 2 and all I get is an error message "Sorry, but your redirection was not created"
No redirection rules entered.
Wil.
Having similar issues here. Worked around by adding manual entries in the MySQL table for redirection items.
I did the same using phpmyadmin.
I have this problem. Do you know what's causing it? Also what is the process to solving it using phpmyadmin?
Hi Exponential
Don't know the exact problem but I suspect it was something to do with running a server on a local machine. Is this what you are doing?
Regardless:
** backup your database before making changes with phpmyadmin **
1. open up phpmyadmin
2. select your WordPress DB
3. select the "wp_redirection_items" table
4. Click on the "Insert" tab along the top of the main window
5. enter "1" into the value field for "id"
6. enter "/home" into the value field for "url"
7. enter "Home" into the value field for "title"
8. Click on "Go"
This should create a new entry in the redirection table.
Refresh the plugin's settings and edit the entry.
Let me know if this works.
Wil.
I'm seeing this same problem. It has worked perfectly up until now. I have been using the plugin since it first came out and it appears to have broken with WP 3.1. I can create redirects in the db manually and the redirects work but everytime I try to add one through the admin I get "Sorry, but your redirection was not created"
Hi bhelms.
Are you running a local dev/test server or is this happening on a live internet server?
I didn't have any problems after 1 manual entry in the table on my wordpress (internet server).
There's an ajax function call in ajax.php line 363.
It calls the Red_Item:create function with the info you entered into the admin form.
The Red_Item classes for adding a new redirection are in the file /modules/redirect.php
The create function starts on line 168.
Something is going wrong in here and it's returning a false.
Didn't have any time to step through the code. That's as far as I got in tracing the issue.
I had though of testing the $wpdb object after the instert query on line 209.
Maybe someone else can do this as I don't really have the time at the moment.
Hope this helps.
Wil.
Hi Will,
I followed your instructions regarding entering a manual entry but I got the following error:
MySQL said:
#1292 - Incorrect datetime value: '' for column 'last_access' at row 1
I am working on a live internet server
Any ideas?
OK - depending on how you've got phpmyadmin setup, you may have to enter valued for those not-null fields.
Try adding a date into the last_access value field and try again 01/01/2010
Or click check the "Partial Import" option then retry adding your values.
Wil.
I'm having the exact same problem. I had it working before on 3.0 and now I'm on 3.0.5 and it's not able to create new redirects. I've made several changes since I last saw it working, so it's impossible for me to track it down.
I couldn't track the problem any farther in code than Wil could.
Think I have find the solution. I created a group called Redirections under the Groups settings for the plugin. Then I could create redirections. Hope that it will work for you also.
i have tried this but it did not work for me...
I already have two groups automatically they are:
- Redirections
- Modifications
When adding another group I still get the same error message :(
Hmm, strange. Well have you done the last upgrades for both WP and redirection?
Yes, Running the latest update of both (I believe). I am not being prompt for any updates
I'm having the same issue. Upgraded to 3.0.4, and suddenly I can't add or edit any redirections. It tells me, "Sorry, but your redirection was not created". I'm afraid to delete the plugin because I don't want to lose all the redirections that are still working.
Thanks.
Hi Exponential & mmmmdave
At this point I think you should check the DB privs your wordpress DB user has.
This DB user (set in the wp-config.php file) should have access to UPDATE the wp_redirection_* tables.
If you have access to MySQL Admin or phpmyadmin then plase check that your wordpress DB user has rights to update those tables.
Sometimes reapplying the DB user rights will recitfy any issues.
Let me know.
Wil.
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')
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
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.
Wil.
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;
else
$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.
Wil.
@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.
Regards,
Wil.
@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.
Thanks,
-Mike
======================
@bhelms - it's http://www.gravitationalfx.com
@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?
Wil.
@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 http://www.exponentialtraining.com it says
"Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in C:\Inetpub\wwwroot\www.exponentialtraining.com\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.
Exponential
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 ) );
This topic has been closed to new replies.