I just had to remove (.+) and everything works as expected. That %1 makes the job. (.*) could be used as well. But with undefined %1 the trick works as well.
I have another question. Is it possible to store the redirection information not in the .htaccess, but in TVs for example.
I want to use the TV ’oldUrl’ to store the old URL.
And I want to make a plugin that would be started OnPageNotFound.
The plugin will get the current not existing URL, find it in the TV table, get the docid and sendRedirect.
I am not quite sure that I do it right, but here is the code.
$TVname = 'oldUrl';
$current = urldecode(_GET['effective_url']);
$table = $modx->getFullTableName("site_tmplvars");
$TVid = mysql_fetch_row($modx->db->select('id', $table, "name = $TVname"))['id'];
$table = $modx->getFullTableName("site_tmplvar_contentvalues");
$doc = mysql_fetch_row($modx->db->select('contentid', $table, "value=$current and tmplvarid=$TVid"))['contentid'];
$url=$modx->makeUrl($doc);
$modx->sendRedirect($url, 1);