Remove subdirectories from admin URL with .htaccess I have Craft public files set up within subdirectories of a primary domain’s web root.

public_html/ # default web root
public_html/example.com/public_html/ # Craft public files here


The following .htaccess rules allow for the public_html subdirectory to act as the new web root. This is the .htaccess within the first public_html directory.

RewriteEngine on

RewriteCond %{HTTP_HOST} ^example.com$
RewriteCond %{REQUEST_URI} !^/example.com/public_html/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /example.com/public_html/$1

RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(/)?$ example.com/public_html/index.php?p=$1 [QSA,L]


It works until I go to example.com/admin.

I can login and cp works, but the URL is http://example.com/example.com/public_html/admin/dashboard

I'd like to remove the subdirectories from the above admin URL for mere aesthetic reasons, but can’t seem to nail it down.

Note: When going directly to http://example.com/admin/dashboard, for example, the URL remains as is, but all the internal links have the subdirectories.
I have Craft public files set up within subdirectories of a primary domain’s web root.
The following .htaccess rules allow for the public_html subdirectory to act as the new web root.

Is there a reason you're doing it this way? The .htaccess you have is only rewriting the content, it's not actually setting the web root. You're basically asking Apache to serve content out of the root for your other domain. There's only a couple circumstances I can think of where you'd need to actually do that (mirroring a domain for example but that's not something you probably want to do here).
For that, you need to set Apache's DocumentRoot properly for your second domain.
It sounds like you have a  CPanel based setup, where it's common for it to put add-on domains inside of the web root of the primary domain by default.  I'm not sure how the document root got changed to the primary domain but you need to set the document root of the add-on domain to the proper place (in Cpanel it's usually the Modify Domain function).
What you type in depends on your path but it's probably set to just public_html now. You want public_html/example.com/public_html/.
That'll get you back to a properly functioning setup.  Then just use Craft's default .htaccess file.