[SOLVED] PHP Enabled Websites Not Directed Correctly

Hi.

Problem Description
I’m trying to setup a website that should be directed to an index.php but constantly gets directed to an index.html.

Steps to Reproduce

  1. Create website folder and files under /var/www/mysite.com/public_html → grant apache ownership
  2. Create and enable apache configuration with following and successfully get letsencrypt certificate
Define servername mysite.com
<VirtualHost *:80>
    ServerName mysite.com
    ServerAlias www.mysite.com
    Redirect / https://mysite.com

</VirtualHost>
<VirtualHost *:443>
    ServerName mysite.com
    ServerAlias www.mysite.com
    ServerAdmin myemail.com
    DocumentRoot /var/www/mysite.com/public_html
 
    <Directory /var/www/mysite.com/public_html>
        Options -Indexes +FollowSymLinks
        AllowOverride All
    </Directory>

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

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

</VirtualHost>
  1. Open any browser and go to https://mysite.com → goes to https://mysite.com/index.html and turns out unreachable
  2. Change address to https://mysite.com/index.php → site works successfully

Expected Outcome
When I use my browser to https://mysite.com, I shouldn’t have to add index.php at the end. Instead I would like to make use of DirectoryIndex for apache to point to .php if .html is not found.

Suggestion
I beleve the cause is /etc/apache2/conf-enabled/freedombox-apache-homepage.conf

RedirectMatch "^/$" "/index.html"

is overriding any attempt I make in apache reaching an index.php file if it cant find a index.html.

Request for Help
I would appreciate if anyone can help me solve this issue without braking the Plinth interface.

Information

  • FreedomBox version: 23.6
  • Hardware: Pi4 - arm64
  • How did you install Fre.edomBox?: installed fbx on top of debian image for pi

Thanks everyone

I think I found a workaround to rewrite the redirected page.

Here’s how the apache configuration for my site turned out. I’m not sure if it’s elegant, but it did work. Any comments to better it would be more than welcome.

<VirtualHost *:80>
    ServerName mysite.com
    Redirect / https://mysite.com

</VirtualHost>
<VirtualHost *:443>
    ServerName mysite.com
    DocumentRoot /var/www/mysite.com/public_html

    <Directory /var/www/mysite.com/public_html>
        <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteRule ^/index.php/(.*)$ /$1 [R,L]
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php [L]
        </IfModule>
    </Directory>
 
    <Directory /var/www/mysite.com/public_html>
        Options -Indexes +FollowSymLinks
        AllowOverride All
    </Directory>

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

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

</VirtualHost>