$s = ' 1 2 3 4 5 6 7 8 9 10 11 12 ';
$s = str_replace(' ', ' ', $s);
# get keywords
$a = array();
# 1 word
$a = array_merge($a, mb_split(' +', $s));
# 2 words
preg_match_all('/ [^ ]+ +[^ ]+ /isu', $s, $m);
$a = array_merge($a, $m[0]);
preg_match_all('/ [^ ]+ +[^ ]+ /isu', ' ! ' . $s, $m);
unset($m[0][0]);
$a = array_merge($a, $m[0]);
# 3 words
preg_match_all('/ [^ ]+ +[^ ]+ +[^ ]+ /isu', $s, $m);
$a = array_merge($a, $m[0]);
preg_match_all('/ [^ ]+ +[^ ]+ +[^ ]+ /isu', ' ! ' . $s, $m);
unset($m[0][0]);
$a = array_merge($a, $m[0]);
preg_match_all('/ [^ ]+ +[^ ]+ +[^ ]+ /isu', ' ! ! ' . $s, $m);
unset($m[0][0]);
$a = array_merge($a, $m[0]);
$a = array_unique($a);
natsort($a);
$a = preg_replace('/ +/', ' ', $a);
print_r($a);
RewriteRule ^tags/([^/]+)$ /$0/ [L,R=301]
RewriteRule ^tags/([^/]+)/$ /tags.php?slug=$1 [L]