Support » Networking WordPress » Multisite 404 on subdomain admin

  • Resolved shellig

    (@shellig)


    Main site: http://www.beesatlanta.com
    subdomains:
    shellig.beesatlanta.com Document root: /public_html/shellig.com (shellig.com)
    prepared4it.beesatlanta.com Document root: /public_html/prepared4it.com (prepared4it.com)
    These subdomains had already been created before I installed wordpress at all.

    None of these sites have any real content (learning before doing).
    http://www.beesatlanta.com – I had installed wordpress previously. This is my primary site configured in cPanel.
    shellig.beesatlanta.com has a SitePad page on it – again, just seeing what is available. After that, I decided I did not like that and would just use WordPress for all the sites. I read a little as I did not really want to try to figure out how to install and manage WordPress for each site separately and followed the instructions here: https://www.wpbeginner.com/wp-tutorials/how-to-install-and-setup-wordpress-multisite-network/
    prepared4it.beesatlanta.com – no content at all

    ISSUE: the admin for the subdomains give me a 404. The network and base site for http://www.beesatlanta.com works fine.

    Followed network setup info at wp-admin/network/setup.php:
    Add the following to your wp-config.php file in /home/beesatla/public_html/ above the line reading /* That’s all, stop editing! Happy blogging. */:

    define(‘MULTISITE’, true);
    define(‘SUBDOMAIN_INSTALL’, true);
    define(‘DOMAIN_CURRENT_SITE’, ‘www.beesatlanta.com’);
    define(‘PATH_CURRENT_SITE’, ‘/’);
    define(‘SITE_ID_CURRENT_SITE’, 1);
    define(‘BLOG_ID_CURRENT_SITE’, 1);

    Add the following to your .htaccess file in /home/beesatla/public_html/, replacing other WordPress rules:

    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).*) $1 [L]
    RewriteRule ^(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]

    I verified with my host (GreenGeeks) that
    • AllowOverride is set to All in httpd.conf
    • *.beesatlanta.com subdomain is created and pointing to /public_html

    At this point, I am stumped as to what to do. The only strange thing is the www in the wp-config has to be there or the network administrator does not work. I also already had the subdomains configured and used the same settings in WordPress as in cPanel if that has any impact.

    Any help appreciated.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator bcworkz

    (@bcworkz)

    WP subdomains are supposed to be redirected to the public root index.php of the main site. The subdomain from the original request is used by the main WP code to determine which subsite was requested, and WP thus gets the appropriate content from the proper table.

    It appears your subdomains are not doing this, but are going to the original subfolders as though WP did not exist. Make sure there are not other rewrite rules above your WP entry in .htaccess related to your non-main domains or subdomains directing requests to the old subfolders.

    While there should be no conflict between your subdomains and the original subfolders /shellig.com and /prepared4it.com, I’d suggest renaming these to eliminate any potential misdirection by the server. For example /old-shellig.com and /old-prepared4it.com. Your sitepad page will not be accessible, but otherwise this cannot make things any worse and might help.

    If that doesn’t help, assuming the primary URLs for your sub-sites are shellig.com and prepared4it.com, I suggest you switch to subfolder based multisite instead of sub-domain. It’s more reliable and you apparently are only using subdomains as a means to access WP with your other domains, no one really sees these subdomains if your domain rewrites are setup correctly. Visitors will not see subfolders just as well 🙂 You’ll need rewrite rules for the requested domains to go to their respective virtual folders, plus the WP rewrite rules for subfolders are slightly different than subdomain. (Do not create actual subfolders on your server for this) Visitors will see whatever URL you set in the sub-site’s Info tab in the Edit Site screen.

    Thread Starter shellig

    (@shellig)

    Thanks bcworkz, will try that now. The folders and subdomain based URLs were created when I added those domains to the host prior to adding WordPress. I am confused about the cPanel subdomain definition vs the one in WordPress. WordPress does not have the document root indicated anywhere. I guess many people create the subdomain from scratch with a multisite set up but I complicated the issue by already having subdomains and having them with primary URLs that are not the subdomain.domain.com URL. Wondering if I should remove them and start over. If I remove from cPanel, though, I am afraid I will not figure out how to add them back correctly to point to the primary URLs through the external hosts.

    Thread Starter shellig

    (@shellig)

    ok, renamed the folders, added new folders at public_html for shellig & prepared4it and put in an index.html file to make sure they were working for shellig. Works but the subdomain.domain.com/wp-admin is still not working for either one of those.

    here is the .htaccess in its entirety. I do not know what the lscache stuff is for but removing that section does not solve the problem:
    # BEGIN NON_LSCACHE
    ## LITESPEED WP CACHE PLUGIN – Do not edit the contents of this block! ##
    ### marker MINIFY start ###
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} ^(.*)/min/(\w+)\.(css|js)$
    RewriteCond %1/wp-content/cache/$2/$1.$2 -f
    RewriteRule min/(\w+)\.(css|js) wp-content/cache/$2/$1.$2 [L]
    </IfModule>
    ### marker MINIFY end ###

    ## LITESPEED WP CACHE PLUGIN – Do not edit the contents of this block! ##
    # END NON_LSCACHE
    # BEGIN LSCACHE
    ## LITESPEED WP CACHE PLUGIN – Do not edit the contents of this block! ##
    <IfModule LiteSpeed>
    RewriteEngine on
    CacheLookup on
    RewriteRule .* – [E=Cache-Control:no-autoflush]
    RewriteRule ^min/\w+\.(css|js) – [E=cache-control:no-vary]

    </IfModule>
    ## LITESPEED WP CACHE PLUGIN – Do not edit the contents of this block! ##
    # END LSCACHE

    # BEGIN WordPress
    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).*) $1 [L]
    RewriteRule ^(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]

    # END WordPress

    Thread Starter shellig

    (@shellig)

    Newest update. Added a test subdomain in WordPress. It works. There is no folder in Public_HTML and I do not know why I thought there had to be (I guess because there were some before). I will delete the folders as they are not needed. Yah! pointing the Document root to /public_html seems to work…
    So, to sum up, I had a pre-existing subdomain pointing to a folder with subdomain.domain.com configuration but that was incompatible with WordPress multisite.

    I am not really sure I understand why that is true and how I would ever separate these sites if I want to in the future… I will not mark it as resolved to give you guys the opportunity to help me better understand that. Thanks!

    • This reply was modified 2 years, 6 months ago by shellig.
    Moderator bcworkz

    (@bcworkz)

    I can explain but am traveling now. Stay tuned!

    Moderator bcworkz

    (@bcworkz)

    One way or another you can export DB data for one of the sites if you want to separate them. Each site for the most part has its own set of tables. They can be imported into a single WP installation. The table names will need converting, but are otherwise compatible with single WP. You can also export via the export tool, which is “compatible” with a few other CMS platforms. Compatible in quotes because the export/import does not always go perfectly. Sometimes the export file needs to be manually patched to get the transfer to work correctly. YMMV.

    Now, the why of how actual folders cause WP to fail. All WP installations, single and multi, when using “pretty” permalinks, rely upon the requested resource NOT existing on the server as a normal file. When the server cannot find what was requested, it sends the request to WP. Based on the requested URL, WP finds the related data in the DB and outputs it based on the appropriate theme template. If a resource actually exists on the server, such as the former subdomain folders you had, the server ignores WP and tries to fulfill the request itself. Of course the problem is wp-admin or whatever do not exist in those old folders, hence the 404 response.

    Remember these lines in the .htaccess?

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    # 3 lines omitted - not relevant to our discussion
    RewriteRule . index.php [L]

    FILENAME in this case actually refers to the entire path/filename. The lines basically say if the requested folder OR requested file are NOT found, send the request to WP’s index.php. index.php then loads the WP environment, then processes the request. Because the request should be a WP permalink, WP knows how to interpret the permalink path and locate the requested resource, outputting it using the appropriate theme template.

    As you can imagine, if the subdomain folders actually exist, these conditions in .htaccess are not fulfilled and thus index.php is not invoked, and WP is not loaded. Make sense now? If not, feel free to ask for clarification on any point. I’m still traveling, but will find my way to a computer once in a while, it just might take a while.

    Thread Starter shellig

    (@shellig)

    Wow thank you so much for the detailed and clear (to me) response! Even though I found this frustrating, the support from you had made the experience worth it.

    I did not know how to get the knowledge to solve the problem and have a much greater understanding now!!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Multisite 404 on subdomain admin’ is closed to new replies.