From the two .htaccess files you posted I can’t see how your site is working at all?!
-
If you request
example.com/(the document root) then the second rule in the root.htaccessfile rewrites the request directly to/subdirectory/index.html(notindex.php). If/subdirectory/index.htmlexists then the (non-WordPress) file is served, otherwise see #2 -
If you request
example.com/foo(wherefoodoes not map to a file or directory) then the first rule in the root.htaccessfile internally rewrites the request to/subdirectory/foo.At which point the
.htaccessfile in the subdirectory rewrites the request back to/index.phpin the document root (not the subdirectory)! This either results in a 404, or a non-WordPress response, or … you’ve have manually createdindex.phpin the document root to somehow initiate WP?!
How you write these directives depends on whether you have another (non-WordPress) site in the document that still needs to be accessible. However, this would also change how you should configure WordPress as well.
For the sake of this example, I assume you only have the domain example.com, in which case there is no need to check the Host header (RewriteCond directive that checks against HTTP_HOST).
If you only have the WP site in the subdirectory and are serving no other files from the document root and you wish to completely “hide” the subdirectory then you can write your directives like this:
Root /.htaccess:
RewriteEngine On
# Unconditionally rewrite everything to the subdirectory
RewriteRule (.*) subdirectory/$1 [L]
The .htaccess file in the subdirectory (below) prevents a rewrite loop.
/subdirectory/.htaccess
Either remove the RewriteBase directive altogether and remove the slash prefix on the RewriteRule substitution string:
# BEGIN WordPress
# :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
Or, (the “WordPress way”), hardcode the /subdirectory:
# BEGIN WordPress
# :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdirectory
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subdirectory/index.php [L]
</IfModule>
(The RewriteBase directive is not actually required in the above, but this is often how it is expressed in WordPress tutorials.)
Then, under Settings > General in WordPress, you would set both the “WordPress Address (URL)” (or WP_SITEURL constant) and the “Site Address (URL)” (or WP_HOME constant) to the site root https://example.com (no /subdirectory).