Access WordPress site running on localhost through localtunnel

I have no problems sharing static sites through localtunnel (http://progrium.com/localtunnel/), but I can’t seem to make a WordPress site work.

My local WordPress site is running on a MAMP server with no issues.

Read More

I’m not exactly sure what the problem is either. I’m thinking it might have something to do with the MySQL database not being accessible?

Can anyone tell me how to access a WordPress site running on localhost through localtunnel?

Thanks for reading.

Related posts

Leave a Reply

2 comments

  1. Put this in your wp-config:

    /* THIS IS CUSTOM CODE CREATED AT ZEROFRACTAL TO MAKE SITE ACCESS DYNAMIC */
    /* WORKS FOR LOCALTUNNEL!!!!!! */
    
    $currenthost = "http://".$_SERVER['HTTP_HOST'];
    $currentpath = preg_replace('@/+$@','',dirname($_SERVER['SCRIPT_NAME']));
    $currentpath = preg_replace('//wp.+/','',$currentpath);
    define('WP_HOME',$currenthost.$currentpath);
    define('WP_SITEURL',$currenthost.$currentpath);
    define('WP_CONTENT_URL', $currenthost.$currentpath.'/wp-content');
    define('WP_PLUGIN_URL', $currenthost.$currentpath.'/wp-content/plugins');
    define('DOMAIN_CURRENT_SITE', $currenthost.$currentpath );
    define('ADMIN_COOKIE_PATH', './');
    define('FS_METHOD', 'direct');
    define( 'WP_ENVIRONMENT_TYPE', 'local' );
    

    I’ve used this successfully without WP_CONTENT_URL, WP_PLUGIN_URL, and ADMIN_COOKIE_PATH, but including them here because they were in the original code found here: https://wordpress.stackexchange.com/questions/179559/relative-or-dynamic-site-url-possible