WordPress.org

Ready to get started?Download WordPress

Forums

Trouble with WordPress Multisite with subdomain using custom .htaccess-file (5 posts)

  1. berntpb
    Member
    Posted 1 year ago #

    Hi

    I've set up a WordPress Multisite using subdomains.

    On before hand I checked with the ISP if thay supported wildcard DNS. They did provide it automaticly when you setup your account. So that was taken care of.

    They allso gave me a custom .htaccess file to get it all to work properly on their servers. This goes as follows:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    
    #rewriting wordpress stuff to the root
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} ^/wp-((content|admin|includes)|((cron|login)\.php))
    RewriteCond %{HTTP_HOST} ([a-zA-Z0-9-]+\.([a-z]{2,4})|co\.uk|me\.uk|org\.uk|priv\.no)$
    RewriteRule ^(.*)$ http://%1/%{REQUEST_URI} [L,QSA] 
    
    #rewriting everying that can't be found to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^index\.php$ - [L] 
    
    # uploaded files
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L] 
    
    #rewriting everything else to index.php
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteCond %{REQUEST_URI} !^/wp-(content|admin|includes|login|cron)(\.php)?
    RewriteRule . index.php [L]
    </IfModule>
    
    # END WordPress

    As opposed to the .htaccess setup suggested by WordPress itself:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    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]
    </IfModule>
    
    # END WordPress

    I have of course tested both setups. The setup suggested by WordPress does not work for the subdomains (http://test.bonitas.no), its giving me 404-errors. The main site http://www.bonitas.no works perfectly both front end and back end. The network back end works aswell.

    The .htaccess setup provided by the ISP gives me access as above. And now to the subdomain test.bonitas.no front end. But when I try to access the backend http://test.bonitas.no/wp-admin I'm rerouted to this address: http://www.bonitas.no/wp-signup.php?new=bonitas.no (there is no error messages, and the page shown is the same as http://www.bonitas.no).

    I don't know anything about .htaccess and RewriteRule etc. So bear over with me. But as far as my sense goes, I think that the following rule might be the culprit?

    RewriteCond %{HTTP_HOST} ([a-zA-Z0-9-]+\.([a-z]{2,4})|co\.uk|me\.uk|org\.uk|priv\.no)$
    RewriteRule ^(.*)$ http://%1/%{REQUEST_URI} [L,QSA]

    I'm in dialog with the ISP's support, but I guess that they really don't know either.

    Any suggestion from you experts will be greatly appreciated.

  2. http://test.bonitas.no/ is working by the way.

    RewriteCond %{HTTP_HOST} ([a-zA-Z0-9-]+\.([a-z]{2,4})|co\.uk|me\.uk|org\.uk|priv\.no)$
    RewriteRule ^(.*)$ http://%1/%{REQUEST_URI} [L,QSA]

    That however is the craziest POS I've see someone suggest in a LONG time.

    I would never use it. What the heck did that get born from?

  3. berntpb
    Member
    Posted 1 year ago #

    Yes the http://test.bonitas.no/ is working fine. However http://test.bonitas.no/wp-admin is not. It gets redirected to http://www.bonitas.no/wp-signup.php?new=bonitas.no

    I don't know, but i suspect the above "POS" is to blame for that error?

    I'll try to take that out to see what happens.

  4. berntpb
    Member
    Posted 1 year ago #

    Removed the following from the .htaccess file.

    RewriteCond %{HTTP_HOST} ([a-zA-Z0-9-]+\.([a-z]{2,4})|co\.uk|me\.uk|org\.uk|priv\.no)$
    RewriteRule ^(.*)$ http://%1/%{REQUEST_URI} [L,QSA]

    The http://test.bonitas.no/ works, but the styling is lost. Though not for the main site http://test.bonitas.no. For the http://test.bonitas.no/wp-admin i get a 404.

    I reinserted the code again.

  5. The http://test.bonitas.no/ works, but the styling is lost. Though not for the main site http://test.bonitas.no. For the http://test.bonitas.no/wp-admin i get a 404.

    That's not your .htaccess. Remove that code forever :) It's not needed.

    Go into your httpd.conf file and make sure AllowOverride is set to either 'All' or 'Options All'

    Ask your host if you can't.

Topic Closed

This topic has been closed to new replies.

About this Topic