WordPress.org

Ready to get started?Download WordPress

Forums

WP in subfolder with domain on root (2 posts)

  1. Riccardo
    Member
    Posted 1 year ago #

    I have a particular case to solve: a hosting plan having different domains, all pointing to the hosting root.
    Based on domain visited I directly redirect the traffic to subfolders with a .htaccess on the root folder.

    For basic websites it works for WordPress I have some problems: there's a WP in the root and a WP in a subfolder. When I call "rootdomain.tld/wp-admin/" it replies the root WP, if I call "subfolderdomain.tld/wp-admin/" continues to reply the root WP instead of subfolder WP so I cannot access the backend of subfolder WP.

    The root .htaccess is like this

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(www.)?subfolderdomain.tld$ [NC]
    RewriteCond %{REQUEST_URI} !^/subfolderdomain/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /subfolderdomain/$1 [L]
    RewriteCond %{HTTP_HOST} ^(www.)?subfolderdomain.tld$ [NC]
    RewriteRule ^(/)?$ subfolderdomain/index.php [L]
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    and the .htaccess in the subfolder is this

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /subfolderdomain/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /subfolderdomain/index.php [L]
    </IfModule>
    # END WordPress

    The root WP has
    site_url: http://www.maindomain.tld
    home: http://www.maindomain.tld

    The subfolder WP has
    site_url: http://www.subfolderdomain.tld/subfolderdomain
    home: http://www.subfolderdomain.tld

    The root WP works normally (frontend and backend) while the subfolder WP frontend is ok but I cannot access its backend if I try to login via wp-login.php or wp-admin.

    Any suggestions?

  2. flashrebel
    Member
    Posted 1 year ago #

    Did you solve your problem ?
    Try to call not subfolderdmain/admin, but real destination
    domain.tld/subfolder/admin

Topic Closed

This topic has been closed to new replies.

About this Topic