multisite 404 subfolder same name slug as site


To keep this short, as a disclaimer, I’m not that versed with WordPress, servers, etc, so I might talk gibberish:

The Issue

🠺 I have a multisite root, let’s call it

🠺 This site spawns temporary subsites with a random slug . This means I can’t possibly know the slug beforehand

🠺 I also need to have on the server a folder with the random-site’s slug name

(for example, on the server, the directory structure will be as follows:<random-code>)

🠺 The problem is, if there’s a folder as the slug, the server throw’s a 404 as it expects to reach an index.php in that folder and not be redirected to WordPress

What I found out

Well, looking at the generic .htaccess for a multisite, I realized this condition is the issue:

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

It basically blocks any attempt if there’s an existing folder.

So naturally, I deleted it. Or more like made it

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

And it works fine …

Alas, why it was there in the first place?

I want things to run smooth, so this probably causes an issue so I want to double-check if so and if there is a better solution

Also, a related question out of pure curiosity, how folders like wp-admin where able to bypass that rule

, , , , Nertan Lucian 7 months 0 Answers 102 views 0

Leave an answer