How to redirect specific URL to Subdomain

To redirect example.com/pagecategory/page-single to pagecategory.example.com/page-single, where pagecategory is entirely variable then you can do something like the following at the top of your .htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^([a-z]+)/([\w-]+) https://$1.%{HTTP_HOST}/$2 [R,L]

I’ve limited the “subdomain” (ie. pagecategory) to just the lowercase characters a-z – this is saved in the $1 backreference. Likewise, $2 holds the “page-single”.

Note that this is a 302 (temporary) redirect. Change R to R=301 if this is intended to be permanent, but only once you have confirmed it works as required (to avoid browser caching issues).