I have a subdomain
http://blog.example.com
I would like to redirect it to subdirectory as
https://www.example.com/blog
But not admin(/wp-admin). Admin area should be as it is
http://blog.example.com/wp-admin
currently I have this in my htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
RewriteCond %{HTTP:X-Forwarded-Host}i ^example\.com
RewriteCond %{HTTP_HOST} ^blog\.example\.com$
RewriteRule ^/?(.*)$ https://www.example.com/blog/$1 [L,R=301,NC]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^/?(.*)$ https://www.example.com/blog/$1 [L,R=301,NC]
</IfModule>
and my site URL and WordPress URL is:
WordPress Address (URL) = /blog
Site Address (URL) = https://www.example.com/blog
but this setup redirects every URLs in my website and creating many issues in the backend.
What is the best ways to do this?
wp-includes
that are loaded both in admin and front end.