# Problem to configure static website with Apache

**URL:** https://discuss.freedombox.org/t/problem-to-configure-static-website-with-apache/2353
**Category:** Support
**Created:** [November 11, 2022, 2:05pm UTC](https://discuss.freedombox.org/t/problem-to-configure-static-website-with-apache/2353 "2022-11-11T14:05:07Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![etienne](https://discuss.freedombox.org/letter_avatar_proxy/v4/letter/e/9fc348/32.png) [@etienne](https://discuss.freedombox.org/u/etienne)
#### Post date: [November 11, 2022, 2:05pm UTC](https://discuss.freedombox.org/t/problem-to-configure-static-website-with-apache/2353/1 "2022-11-11T14:05:07Z")

</div>

**Problem Description**  
I’m trying to set up a static website on my Freedombox not by going [the user-based way](https://wiki.debian.org/FreedomBox/Manual/Apache_userdir#Using_User_Websites), but by leveraging a custom Apache config file with a domain name (let’s call it [custom.com](http://custom.com)) that’s not the one used for Plinth (let’s call it [main.com](http://main.com))

I also got a SSL certificate via Let’s Encrypt, so I’m all good here.

**Details**  
Here’s my config at `/etc/apache2/sites-available/01-custom.com` (I used 01 as a prefix to prioritize it over the freedombox config files).

```xml
<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName custom.com
        ServerAlias www.custom.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/custom
        DirectoryIndex index.html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

SSLCertificateFile /etc/letsencrypt/live/custom.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/custom.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

```

Then:

- I place `index.html` in `/var/www/html/custom`.
- I create the symlink in `/etc/apache2/sites-enabled` and reload Apache.

**Expected Results**

I should see the content of that `index.html` at `https://custom.com`.

**Actual results**

When trying to reach my website at `https://custom.com`, I get redirected to `https://custom.com/plinth` - even though this is not the domain name I use for that effect - and my Freedombox home page shows up.

What’s the Apache directive I need to add so that `https://custom.com` shows the content of `/var/www/html/custom/index.html`?

Interestingly, when going to `https://custom.com/category`, it shows correctly the content of `/var/www/html/custom/category/index.html`.

**Alternatively…**

If I choose to go the user-based way, is it possible to have `https://custom.com` to show the content of `https://main.com/~myuser`? I tried to play with a CNAME DNS record, but without success.

---

<div class="post-metadata">

### Author: ![Ged](https://discuss.freedombox.org/user_avatar/discuss.freedombox.org/ged/32/999_2.png) [@Ged](https://discuss.freedombox.org/u/Ged)
#### Post date: [November 22, 2022, 8:42pm UTC](https://discuss.freedombox.org/t/problem-to-configure-static-website-with-apache/2353/3 "2022-11-22T20:42:18Z")

</div>

Hi @etienne

Previously, I totally misunderstood your question. Apologies; I removed my (misunderstood) answer.

Here’s how I tweaked your configuration to get it working:

- Achieve the certificate (you already have)
- If need be, create a new folder for your domains website as described [here.](https://linuxize.com/post/how-to-set-up-apache-virtual-hosts-on-ubuntu-20-04/)
- Remove the `<IfModule>` arguments along with `Include /etc/letsencrytp/options-ssl-apache.conf` to revise your conf file as needed in regard to below

```auto
<VirtualHost *:443>
    ServerName custom.com
    ServerAlias www.custom.com
    ServerAdmin webmaster@custom.com
    DocumentRoot /var/www/custom.com/public_html

    <Directory /var/www/custom.com/public_html>
        Options -Indexes +FollowSymLinks
        AllowOverride All
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/custom.com-error.log
    CustomLog ${APACHE_LOG_DIR}/custom.com-access.log combined

SSLCertificateFile /etc/letsencrypt/live/custom.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/custom.com/privkey.pem

</VirtualHost>

```

- Generate symbolic link with a2ensite
- Restart your apache server with `sudo systemctl reload apache2`

I got this successfully working. Fingers crossed for now.

Take care.

---

<div class="post-metadata">

### Author: ![etienne](https://discuss.freedombox.org/letter_avatar_proxy/v4/letter/e/9fc348/32.png) [@etienne](https://discuss.freedombox.org/u/etienne)
#### Post date: [November 23, 2022, 2:04am UTC](https://discuss.freedombox.org/t/problem-to-configure-static-website-with-apache/2353/4 "2022-11-23T02:04:06Z")

</div>

Thank you very much @Ged for your help and for being thorough as well.  
I got the static website working, thanks to you! Your previous answer was also correct.

The thing that I can’t seem to go away is this redirection: when I go to `custom.com`, it redirects to `https://custom.com/index.html`. I’ve been searching how to get rid off this `index.html` bit that pops up automatically in the URL bar, but no success. I think it’s not a big deal anyway.

Thanks again for your help!

---

<div class="post-metadata">

### Author: ![Ged](https://discuss.freedombox.org/user_avatar/discuss.freedombox.org/ged/32/999_2.png) [@Ged](https://discuss.freedombox.org/u/Ged)
#### Post date: [April 21, 2023, 10:10am UTC](https://discuss.freedombox.org/t/problem-to-configure-static-website-with-apache/2353/5 "2023-04-21T10:10:03Z")

</div>

Hi @etienne

This is a little old, but I came across the problem of my site redirected to `index.html`.  
I believe [this recent post](https://discuss.freedombox.org/t/solved-php-enabled-websites-not-directed-correctly/2550/2) might help.
