Hello
Could you elaborate a little more on the existing configuration in place? You mentioned a redirect to a sub-directory, but then also mentioned deleting that same sub-directory. cPanel should not automatically create directories on it's own without you creating the subdomain in the UI. Do you have any other third-party applications or scripts installed that could be creating the directory?
Thank you.
I created a subdomain in the UI: xxx.domain.com and the directory as public_html
I then created a .htaccess file with the following content:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^xxx.domain.com$
RewriteRule ^/?$ "http\:\/\/domain\.com\/xxx" [R=301,L]
domain.com/xxx is not a directory, it's an application route. Cpanel automatically keeps creating the xxx directory which breaks the route.