WordPress-site can be reached on x.x.x.x/index.php – but not directly on the IP without index.php

Brand new WordPress install with Avade Theme installed on RPi 4 – works fine when I access it on http://203.0.113.111/index.php from an external connection, but if I remove the index.php I get nothing – connection refused.

Is this normal behaviour? Shouldn’t I get redirected to the WP installs index page right away? I’ve forwarded port 80 in my router to the Pi’s internal IP, so I can’t get my head around this.

I even modified the .htaccess in /var/www/html with these lines:

DirectoryIndex index.html index.php

but ALAS – even though I think it should work just fine I don’t get why I have to write the index.php in my web-browser. Of course a direct DNS forward could do the trick here, but common? That’s just symptom-treatment, right?

Can anyone give me a pointer in the right direction?

EDIT: It’s the same when I try to access my web servers internal IP from the LAN – I have to input index.php if I must reach the WP-site.

EDIT 2: from @kero’s comment: I rewrote AllowOverride in Apache conf from None to ALL and restarted Apache but still nothing.

… still changes nothing after an Apache service restart.

2 Answers
2

Is this normal behaviour?

Yes. On a default Apache install, only index.html is set as the DirectoryIndex (the default setting).

Either in the appropriate <VirtualHost> container, or main server config you need to add a <Directory> section that specifically targets the defined document root directory.

For example:

DocumentRoot /var/www/html

<Directory "/var/www/html">
    # Allow public access to the site
    Require all granted

    # FollowSymLinks is required for mod_rewrite
    # (Although this is actually the default server setting)
    Options FollowSymLinks

    # Allow mod_dir to serve index.php by default
    DirectoryIndex index.php

    # Give full access to htaccess (optional)
    # Strictly speaking you only need "FileInfo" for mod_rewrite
    # - Alternatively place all your htaccess directives here...
    AllowOverride All
</Directory>

You will then need to restart Apache.

mod_dir also needs to be enabled, but this should be loaded by default.

Leave a Comment