• Andrew Ryan

    (@andy_intermediate)


    Hi All,

    Goal:

    • I wish to develop on my localhost using multisite subfolders.
    • I need my team members to be able to access my sites from the internet.

    I do assume this is actually possible. Virtual hosts maybe that map to correct folder? I’m still learning the ropes…

    Problem:
    I can access both front and back ends of primary and secondary sites from my internal machine. For example:
    Primary site:      127.0.0.1/wordpress
    Secondary sites: 127.0.0.1/wordpress/s2
                             127.0.0.1/wordpress/s3
                             ...etc

    But whenever I try to access from external machines on internet using
    110.22.25.35/wordpress
    110.22.25.35/wordpress/s2
    …etc
    wordpress redirects to 127.0.0.1/wordpress on the external machine
    Of course, since the external machine has nothing running there it fails to load. Note that secondary sites, eg 110.22.25.35/wordpress/s2 are also redirected to 127.0.0.1/wordpress, not 127.0.0.1/wordpress/s2

    LocalMachine Directory Structure (partial):
    C:\xampp
    C:\xampp\apache
    C:\xampp\mysql
    C:\xampp\apps\wordpress

    MySQL DB from phpMyAdmin (partial):
    bitnami_wordpress/wp-options/siteurl = http://127.0.0.1/wordpress
    bitnami_wordpress/wp-options/home  = http://127.0.0.1/wordpress

    Configuration (partial):
    C:\xampp\apps\wordpress\htdocs\wp-config

    /** MySQL hostname */
    define('DB_HOST', 'localhost:3306');
    ...
    /* Multisite */
    define( 'WP_ALLOW_MULTISITE', true );
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', false);
    define('DOMAIN_CURRENT_SITE', '127.0.0.1');
    define('PATH_CURRENT_SITE', '/wordpress/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);
    ...
    define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/wordpress');
    define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/wordpress');
    ...

    C:\xampp\apps\wordpress\htdocs\.htaccess

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteBase /wordpress/
     RewriteRule ^index\.php$ - [L]
     # add a trailing slash to /wp-admin
     RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
     RewriteCond %{REQUEST_FILENAME} -f [OR]
     RewriteCond %{REQUEST_FILENAME} -d
     RewriteRule ^ - [L]
     RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
     RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
     RewriteRule . index.php [L]
    </IfModule>
    # END WordPress

    C:\xampp\apps\wordpress\conf\httpd-prefix.conf

    Alias /wordpress/ "C:/xampp/apps/wordpress/htdocs/"
    Alias /wordpress "C:/xampp/apps/wordpress/htdocs"
    Include "C:/xampp/apps/wordpress/conf/httpd-app.conf"

    C:\xampp\apps\wordpress\conf\httpd-app.conf
    I’m pretty sure this gets overwritten by C:/xampp/apps/wordpress/htdocs/.htaccess? (so no need for rewrite rule)

    <Directory "C:/xampp/apps/wordpress/htdocs">
        Options +MultiViews +FollowSymLinks
        AllowOverride FileInfo Options
        <IfVersion < 2.3 >
        Order allow,deny
        Allow from all
        </IfVersion>
        <IfVersion >= 2.3>
        Require all granted
        </IfVersion>
    </Directory>

    C:\WINDOWS\system32\drivers\etc\hosts
    127.0.0.1 localhost

    Other Info:

    • I know the gateway (110.22.25.35) is correctly forwarding because non-WP pages are correctly displayed
    • I figure i need to somehow stop wordpress mapping external requests to 127.0.0.1, but don’t know how to do this without breaking everything.
    • Perhaps using VirtualHost, ServerName or ServerAlias somehow?

    Any ideas would be greatly appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Andrew Ryan

    (@andy_intermediate)

    Extra Info:
    Using wireshark, i’ve noted the following:

    1. Router correctly forwards GET request to LAN server machine
      GET 110.22.25.35/wordpress/wp-login.php
    2. LAN server machine responds with a redirect message
      302 Found. Location 127.0.0.1/wordpress/
    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Moving to localhost section.

    Thread Starter Andrew Ryan

    (@andy_intermediate)

    Solved!! All working now.
    Primary and multiple secondary local sites on localhost accessible via internet.

    Steps:

    1. In phpMyAdmin, went to the bitnami_wordpress database
    2. In table wp_blogs changed all 127.0.0.1 to my router’s ip (110.22.25.35)
    3. In table wp_site changed “domain” col from 127.0.0.1 to my router’s ip (110.22.25.35) where id = 1
    4. In table wp_site_meta changed “site_url” from 127.0.0.1 to my router’s ip (110.22.25.35)
    5. I think I changed a few more similarly, but didn’t write it down… sry

    6. In wp-config.php I replaced 127.0.0.1 with my router’s ip (110.22.25.35) , ie
      define('DOMAIN_CURRENT_SITE', '110.22.25.35');
    7. That let me log in as super-admin, I then went to “Network Admin” > “Sites” and edited each site, changing all instances of 127.0.0.1 to 110.22.25.35

    I can now access back and front ends from my local machine and also from the internet.

    A long, long last few days!! 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can't access localhost from Internet using multisite subfolders’ is closed to new replies.