Support » Localhost Installs » Multisite on Localhost with subdomains redirect

  • maxwellss


    Hi all,

    I know this is a well-chewed over topic, but despite trawling forums over days, I haven’t been able to find a topic which gives me an answer.

    I’ve set up multisite on localhost on Windows using XAMPP.

    The problem is a redirect loop when I try to login to my sub-domain dashboards. I can see the test sites themselves at test.xp-home, and test2.xp-home, etc. I can login to the main dashboard at xp-home.

    Up until this, I’d just been doing separate installs for each build, and adding the subdomain to httpd-vhosts.conf, and editing my hosts file. That’s worked fine, but I’m trying to streamline things so that I can manage plugins and themes centrally.

    This is a sample of my hosts file; localhost
    . xp-home
    . test.xp-home test2.xp-home

    This is my .htaccess file under the web root;

    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)$ wp/$1 [L]
    RewriteRule . index.php [L]

    This is a sample of my vhosts file;

    <VirtualHost *:80>
    DocumentRoot "C:/Users/admin/Documents/web"
    ServerName xp-home
    #ServerAlias xp-home *.xp-home
    <Directory "C:/Users/admin/Documents/web">
    AllowOverride All
    Options +MultiViews +FollowSymLinks
    ErrorLog logs/error.log
    CustomLog logs/access.log combined

    and at the bottom….

    <VirtualHost *:80>
    DocumentRoot "C:/Users/admin/Documents/web"
    ServerAlias *.xp-home
    ErrorLog logs/error.log
    CustomLog logs/access.log combined

    Can someone please point out what I’m doing wrong here?

    Many thanks in advance,

Viewing 1 replies (of 1 total)
  • Abhishek Ghosh


    What you actually want to do is using symlink. symlink in Windows….you are in Windows environment and trying to mock UNIX environment. So, we need to symlink.

    mklink <arguments> <symlink> <targetoflink>

    /j option is softlink, /h option is hardlink.


    mklink /j "c:\users\Who\wants\the\folder" d:\Can\symlink\

    Do not use .htaccess rules.

    I have not checked your settings in the coding part, just I am taking they are right as you have said you can open test.xp-home, and test2.xp-home, etc.

    This is quite commonly done on Debian based servers. You can not symlink the root folders because the wp-config should be different. You can actually can refer the files. In other words, test.xp-home can have empty wp-admin. Because after symlinking :

    test.xp-home/wp-admin/ means xp-home/wp-admin/

    But, if you do 301 / 302 redirection :

    test.xp-home/wp-admin/file.php has been moved to xp-home/wp-admin/file.php

    This will create an infinite loop of redirection as the users must be logged in to manipulate the files but wordPress is not understanding what is happening. On test.xp-home/wp-admin/ the user is initiating a call to test.xp-home/wp-admin/xp-home/wp-admin/plugins.php (for example) but it is redirecting to xp-home/wp-admin/plugins.php ; xp-home/wp-admin/plugins.php can not validate the call, because it only can be called from xp-home/wp-admin/xp-home/wp-admin/plugins.php for security.

Viewing 1 replies (of 1 total)
  • The topic ‘Multisite on Localhost with subdomains redirect’ is closed to new replies.