Try using this:
if (!is_admin()) {
add_rewrite_rule('([A-Za-z0-9])/([A-Za-z0-9])', 'index.php/product?subcategory=$1&product=$2', 'top');
add_rewrite_rule('([A-Za-z0-9])', 'index.php/categories/?cat=$1', 'top');
}
Try using this:
if (!is_admin()) {
add_rewrite_rule('([A-Za-z0-9])/([A-Za-z0-9])', 'index.php/product?subcategory=$1&product=$2', 'top');
add_rewrite_rule('([A-Za-z0-9])', 'index.php/categories/?cat=$1', 'top');
}