URL rewrite for mu-plugin assets
I have a semi-bespoke scenario, but one that works best for out environment sharing the code workload and accessibility (and version control).
We have a multisite that all abide by the same core styles, scripts, fonts, and images.
We converted those out of a parent theme into a mu-plugin as the plugin handles a lot more than those (activation, API functions, etc.)
Previously, we were using a standard WordPress install and had .htaccess
doing the rewrite which was fine:
<IfModule mod_rewrite.c>
...
# rewrites
RewriteRule ^css/(.*) wp-content/mu-plugins/core/resources/css/$1 [QSA,L]
RewriteRule ^font/(.*) wp-content/mu-plugins/core/resources/font/$1 [QSA,L]
RewriteRule ^img/(.*) wp-content/mu-plugins/core/resources/img/$1 [QSA,L]
RewriteRule ^js/(.*) wp-content/mu-plugins/core/resources/js/$1 [QSA,L]
...
</IfModule>
But I was wondering is there a way to do this without having to edit the .htaccess
file? I looked into endpoints thinking I could get the files as:
http://domain.ltd/core/css/file.css
http://domain.ltd/core/font/file.svg
http://domain.ltd/core/img/file.img
http://domain.ltd/core/js/file.js
The aim is that once you install the plugin you didn’t have to worry about the htaccess
file the plugin itself handled the routing for the url and prettied.
Leave an answer
You must login or register to add a new answer .