I just moved my subdomain multisite to a new server and I'm having some trouble with permalinks & redirects.
One difference post-move is that I have moved core WP files into it's own directory /wp
(see roots/bedrock folder structure.
Now when I try to access /wp/wp-admin
, I am redirected to /wp-login.php?redirect_to=...
which comes up as a 404 of course because that file does not exist.
However, if I comment out the multisite constants in the config, I am able to access wp-admin as a non-multisite without issue (which is how I was able to make sure I have the right .htaccess below - from Tools > Network Setup).
I have .htaccess
setup with the rules instructed by WP for multisite:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) wp/$1 [L]
RewriteRule ^(.*\.php)$ wp/$1 [L]
RewriteRule . index.php [L]
The other problem is that even with multisite off, I get a 404 when trying to go to any page other than the homepage.
I've read that multisite stores some path info in the DB, so perhaps a search/replace is necessary?
Update 1
I was able to resolve* the problem I had with the redirect to 404 when trying to access wp-admin. This was simply due to changes that needed to be made in the database for the siteurl
. I was of the understanding that this value was superceeded by the WP_SITEURL constant. This does not seem to be the case with Multisite - probably because it has to be different for each site. Once I corrected the siteurl
in the options table for each site, that site would work (wp-admin could be reached).
2 Problems remain
Permalinks are still not working as they should. Now that I can access wp-admin, I have gone in, and resaved to update the permalink structure which seems to have no effect. By not working, I mean I get a 404 when navigating to anything away from the front page of that site.
Network admin is inaccessible via the admin bar. The URL for Network admin it's giving me is missing the
/wp
directory. If I access it directly,/wp/wp-admin/network/
-- it works. For some reason, the generated URLs in the admin bar are missing this and are broken. If I changedefine('PATH_CURRENT_SITE', '/');
todefine('PATH_CURRENT_SITE', '/wp/');
, those URLs are correct, but trying to access them fails. That does not seem like the right thing to do in this case as one would expect that to be shown under/wp-admin/network/setup.php
. After some digging, I found that these links are generated bynetwork_admin_url()
. Essentially the responsible line of code isset_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme );
fromnetwork_site_url()
.
Update 2
I was able to resolve the permalink issue. As it turns out it was actually the virtual host configuration in apache! I had AllowOverride none
set for my site's <Directory>
directive, which I think was preventing any of the .htaccess rewrite rules from being applied. I should've realized earlier that this was the case as the 404 I was getting was from apache, not wordpress...
The only remaining weirdness at this point is the wrong url generated by network_admin_url()
. Will post an answer if I figure this out.
home
, site domains).