This is the working code:
add_action('init', 'rewrite_init'); // Rewrite
add_action('query_vars', 'rewrite_query_vars');
add_filter('template_include', 'rewrite_template_include');
function rewrite_init(){
add_rewrite_rule('([^/]+)/([0-9]+)/?$', 'index.php?catname=$matches[1]¤tpage=$matches[2]', 'top');
add_rewrite_rule('cam/([^/]+)/?$', 'index.php?name=cam&perf=$matches[1]', 'top');
}
function rewrite_query_vars($query_vars){
$query_vars[] = 'currentpage';
$query_vars[] = 'catname';
$query_vars[] = 'perf';
return $query_vars;
}
function rewrite_template_include($template){
if(get_query_var('currentpage') || get_query_var('catname')){
$template = locate_template(array('category.php'));
} elseif(get_query_var('perf')){
$template = locate_template(array('single.php'));
}
return $template;
}