Website Module: Images and CSS not loading (404) when running from Root Domain via custom index.php

Hi everyone,

I am using Dolibarr v23.0.2 and having trouble with the Website Module.

My Setup:

  • ERP Path: /public_html/erp/ (Subdomain: erp.expotradersbd.com)

  • Target Website: https://expotradersbd.com (Root domain)

  • Data Path: /home/expotfya/dolibarrdata/

The Problem: I have successfully regenerated all 18 pages. The text content is showing up correctly on the root domain, but all images, CSS, and JS files are returning 404 errors.

What I have tried so far:

  1. I created an index.php in the root to include the generated files from dolibarrdata/website/.

  2. I configured .htaccess to redirect theme/ and includes/ to the ERP folder.

  3. I set WEBSITE_FORCE_RELATIVE_URLS to 1 in Other Setup.

  4. I cleared all browser caches and regenerated the site multiple times.

The Error: My browser console shows that it’s looking for images at: expotradersbd.com/medias/image/www.expotradersbd.com/background.jpg But this returns a 404 Not Found. It seems the root index.php doesn’t know how to handle the /medias/ requests and pass them to Dolibarr’s viewimg.php correctly.

Request: Can anyone provide the exact logic for the root index.php and .htaccess so that it correctly serves media files and CSS when the site is accessed via the root domain while the ERP is in a subdirectory?