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

**URL:** <https://www.dolibarr.org/forum/t/website-module-images-and-css-not-loading-404-when-running-from-root-domain-via-custom-index-php/31117>\
**Category:** Maintaining my Dolibarr\
**Tags:** Linux\
**Created:** [April 10, 2026, 6:34am UTC](https://www.dolibarr.org/forum/t/website-module-images-and-css-not-loading-404-when-running-from-root-domain-via-custom-index-php/31117 "2026-04-10T06:34:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tofazzal88](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/t/4491bb/32.png) [@tofazzal88](https://www.dolibarr.org/forum/u/tofazzal88)\
**Post date:** [April 10, 2026, 6:34am UTC](https://www.dolibarr.org/forum/t/website-module-images-and-css-not-loading-404-when-running-from-root-domain-via-custom-index-php/31117/1 "2026-04-10T06:34:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dolix](https://www.dolibarr.org/forum/letter_avatar_proxy/v4/letter/d/e5b9ba/32.png) [@dolix](https://www.dolibarr.org/forum/u/dolix)\
**Post date:** [October 26, 2026, 5:56pm UTC](https://www.dolibarr.org/forum/t/website-module-images-and-css-not-loading-404-when-running-from-root-domain-via-custom-index-php/31117/2 "2026-10-26T17:56:39Z")

</div>

Hi,

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](http://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:

```auto
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).
