We wanna make a redirection from root domain to a subfolder
We already tried: '''
RewriteCond %{HTTP_HOST} ^example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule (.*)$ https://example.com/folder1/subfolder/$1 [R=301,L]
''' The redirection works, but internal files also prepend the folder structure so web page doesn´t work as expected.
Thank you very much in advance
Your issue is that those rules also get applied to requested URLs that already contain the rewritten folder structure. So you need to add an exception for those cases:
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteCond %{REQUEST_URI} !^/folder1/subfolder/
RewriteRule (.*)$ https://example.com/folder1/subfolder/$1 [R=301,END]
Such rules should get implemented in the actual http server's host configuration if possible. When using a distributed configuration file instead (".htaccess") you need to accept a performance penalty...