I am a sysadmin with some experience in PHP and databases, but a complete Newbie to Drupal.
I have a Drupal site I am hosting but it needed to be moved away from the web root to host a new website altogether. So I moved it from public_html to public_html/archived/. While doing this I updated the htaccess file and drupal's settings.php to make sure references to the root directory / are replaced with /archived/ (including example.com to example.com/archived/. The website loaded but several images and styles were missing. Inspecting the rendered HTML showed that all the style attributes in different tags got prepended by /archived/. So something like:
<div style="width:100%">
became <div style="/archived/width:100%">
I have never seen this kind of behavior. And I am not sure if this was because of the changes in htaccess or settings.php, or if there is some theme level code doing this.
Just to try my luck, I moved the website from /public_html/archived to /archived/ and pointed a subdomain archived.example.com to it. I updated htaccess and settings.php again. The same issue happened with the style attribute
<div style="/width:100%">
Here are the changes I am doing in .htaccess
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://archived.example.com/$1 [L,R=301]
RewriteBase /
And here is what I am updating in /sites/default/settings.php
$settings['trusted_host_patterns'] = [
'^archived\.example\.com$'
];
There is also this in settings.php
$settings['file_public_base_url'] = 'https://archived.example.com/';
But I have commented it out right now.