Can I add a rewrite in htaccess to remove WordPress Multisite subdirectory from URL?

I am working on a Multisite that was installed and activated on an old version of WordPress. The WP files were placed in a subdirectory named wp and now a request has been made for the subdirectory to be removed from the URL, i.e. the site’s and subsites’ web addresses should be domain.com, domain.com/subsite and not domain.com/wp/, domain.com/wp/subsite.

Rather than moving the WordPress files out of the /wp/ subdirectory, can I use a rewrite rule in the htaccess file to make it such that the URL shows https://domain.com and https://domain.com/subsite/pages and serve the content from https://domain.com/wp/ and https://domain.com/wp/subsite/pages?

The comment given for a similar question (Suppress subdirectory from WordPress Multisite primary URL) referenced the codex but this multisite was installed and activated with a version older than 3.5 and looks like SubFolder Example – WordPress 3.0 through 3.4.2 containing these lines, which do not appear in Method I (Without URL change):

#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L]

Can I follow the codex entry and replace my current htaccess file with the version shown in Method I (Without URL change)?

I also spoke with the hosting provider’s tech support and their recommendation was to do the reverse: rather than move the WP files from the root folder to the subdirectory their suggested course of action was to move all the files in the subdirectory into the root and make further changes using phpAdmin.

I’ve combed through the WordPress Stack Exchange, web articles and the Codex and am having a difficult time deciding on a course of action.

Read more here:: Can I add a rewrite in htaccess to remove WordPress Multisite subdirectory from URL?

Leave a Reply

Your email address will not be published. Required fields are marked *