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:
I created an index.php in the root to include the generated files from dolibarrdata/website/.
I configured .htaccess to redirect theme/ and includes/ to the ERP folder.
I set WEBSITE_FORCE_RELATIVE_URLS to 1 in Other Setup.
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?
The site folder Dolibarr generates (/home/expotfya/dolibarrdata/website/www.expotradersbd.com/) is more than the pages: it also holds styles.css.php, javascript.js.php, one .php file per page and a “medias” link to dolibarrdata/medias. The pages ask for /medias/…, /styles.css.php and so on at the root of the domain, so with only your index.php in public_html they all give 404. No need to go through viewimage.php.
I reproduced it on a fresh 23.0.4 with the 18-page “corporate” template: with an index.php that includes the generated page, the text shows, and CSS, JS, images and the other pages are 404.
The intended way, which worked: set the document root of expotradersbd.com to /home/expotfya/dolibarrdata/website/www.expotradersbd.com (Apache must allow symlinks there, for the medias link).
If your host won’t let you change the document root of the main domain, this also worked: remove your index.php from public_html and link the files of the site folder instead:
cd /home/expotfya/public_html
for f in /home/expotfya/dolibarrdata/website/www.expotradersbd.com/*; do ln -s "$f" .; done
Page, CSS, JS, images and the other pages all came back 200 (symlinks must be allowed here too). When you add a page in Dolibarr later, run the loop again (it only complains about the links that already exist).