.oO turn on ~ tune in ~ drop out Oo.
How to fix broken WordPress permalinks using .htaccess rewrite rules
How to fix broken WordPress permalinks using .htaccess rewrite rules

How to fix broken WordPress permalinks using .htaccess rewrite rules

You might run into permalink issues in WordPress installations which cause WordPress posts/pages to return “404 Not Found” error codes. In my case the default permalink setting “plain” worked fine until I switched over to “postname” (for SEO reasons) or any other permalink setting. This issue is most likely caused by installed WordPress plugins, which modify/redirect incoming http/https requests.

The WordPress plugin ReallySimpleSSL for instance, takes care about
changing the WordPress site URL / home URL to https and redirects all incoming requests to https as well.

ReallySimpleSSL point out on their homepage that using a .htaccess redirect “is a recommended setting, because the .htaccess redirect is slightly faster, and the WordPress [301] redirect might be less reliable in combination with caching“.

Following their advise the recommended setup should look like this:

If this option is enabled, ReallySimpleSSL modifies the .htaccess file somehow similar like this:

# BEGIN rlrssslReallySimpleSSL rsssl_version[3.2.6]
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
# END rlrssslReallySimpleSSL

So what does this mean particularly?

IfModule checks if an module called mod_rewrite.c is in place and installed correctly.
RewriteEngine enables the rewrite engine in general.
RewriteCond defines conditions under which rewriting takes place.
RewriteRule defines rules for the rewriting engine.

https://www.wpbeginner.com/wp-tutorials/how-to-fix-wordpress-posts-returning-404-error

UPDATE:

Just a side-note how WordPress handles a Multi-Site configuration:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]