WordPress Multisite: index.php automatically appears in URL

1. Caddy version: v2.4.6

2. How I installed, and run Caddy:

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

a. System environment:

Ubuntu 20.04 LTS

b. Command:

caddy run

c. Service/unit/compose file:

NA

d. My complete Caddy config:

{
on_demand_tls {
ask https://microweb.app
interval 2m
burst 5
}
}
https:// {
tls {
on_demand
}
root * /home/forge/microweb
file_server
php_fastcgi unix//run/php/php8.0-fpm.sock
}

thinkfinserv.com {
redir https://www.thinkfinserv.com{uri}
}

3. The problem I’m having:

I’m running the above configuration to host a WordPress Multisite; with subdomain configuration. I’ve had permalinks set-up to /%post% for a while which gave me clean urls like artha.microweb.com/post-name.

Today, I logged in to create a new site and found out that wordpress’s permalink structure began showing index.php in the permalink settings. For example: https://artha.microweb.app/index.php/sample-post/

I did not change any settings on my own on the Caddy front or even on WordPress settings that’d trigger this change. I’ve only upgraded WordPress to its latest version; and I’ve no clue why’d WordPress begin showing index.php in URLs.

When I create a new post, it automatically tries to include index.php in the URL, HOWEVER, the clean url works. That is

→ When I create the post, the url is shown as /index.php/good-world/ which throws 404
→ BUT if I visit /good-world/ → the page loads fine.

I’m super confused by this behavior. Can’t figure out why’d this happen.

I don’t know if this is a result of upgrading wordpress or something else. My best guess is that .htaccess has nothing to do with this, but I’ll post the recommended .htaccess configuration by wordpress in my network admin below -

4. Error messages and/or full log output:

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

5. What I already tried:

I’ve already tried verifying my Caddyfile configuration; which seems to be unaltered. Let me know if this looks like a WP issue and not a Caddyfile issue.

6. Links to relevant resources:

That’s quite an old version. Please upgrade to v2.6.2.

Your Caddyfile formatting is pretty broken here. Please use caddy fmt to clean up indentation. It’s hard to read otherwise.

I can’t really help with that. That’s a question that requires understanding of WordPress internals. Might be best if you ask in WordPress support forums.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.