How to add a file to root directory of multisite
Lets say we have lots of websites by using WordPress multisite feature and we want to add a file to root directory of each file. This can be done easily by using single directive in .htaccess file.
- First of all, upload the file to the hosting account. It may be uploaded to WordPress installation directory. For example, if it’s uploaded to “public_html/wp-content/file” and the permalinks structure is set to domain.com/file/file.txt, but we want it to be accessible over domain.com/file.txt.
- Open .htaccess file for editing. Usually it can be found in the public_html of WordPress installation directory.
- Insert the following line to set redirect action:
RewriteRule ^file.txt /file/file.txt [L]
- Save and close .htaccess file to apply the changes and check how redirect is working in live websites.