URL rewriting in wordpress using parameters

I ended up scrapping the WordPress solutions described and WordPress all together for this project and building my own basic front end.

Using this answer: https://technicalseo.com/tools/htaccess/ I was able to create a rule for each possibility.

Bear in mind, the URL must contain index.php in order to work and URL parameters are not passed to the script unless QSA is appened, but this adds them to the URL which defeats the purpose.

Here is what I ended up doing in my htaccess file:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^loc=(.*)&cat=(.*)&sub=(.*)$
RewriteRule ^index.php$ /%1/%2/%3/? [L,R=301]

RewriteCond %{QUERY_STRING} ^loc=(.*)&cat=(.*)$
RewriteRule ^index.php$ /%1/%2/? [L,R=301]

RewriteCond %{QUERY_STRING} ^loc=(.*)$
RewriteRule ^index.php$ /%1/? [L,R=301]

RewriteCond %{QUERY_STRING} ^name=(.*)$
RewriteRule ^index.php$ /%1/? [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

I’m sure there is a way to do this in WordPress and I got close using the Redirection plugin, but ran out of time after testing a few hundred possibilities.

Be careful with Redirects and caching, also if using WordPress you need to update your permalinks each time you change a rule.