Skip to content

Instantly share code, notes, and snippets.

@kjbrum
Last active May 21, 2016 02:21
Show Gist options
  • Save kjbrum/7695b1c529571a343370 to your computer and use it in GitHub Desktop.
Save kjbrum/7695b1c529571a343370 to your computer and use it in GitHub Desktop.
Access projects being served on your localhost to other devices on the same network, keeping CSS, JS and images intact (add to wp-config.php file before settings). View at: your-ip-address/project-folder
<?php
/** Access localhost on same network **/
$IP = $_SERVER['HTTP_HOST'];
$projectDir = 'projectfolder';
$localIPs = array( '127.0.0.1','::1' );
if( !in_array( $_SERVER['REMOTE_ADDR'], $localIPs ) ) {
define( 'WP_SITEURL', "http://$IP/$projectDir" );
define( 'WP_HOME', "http://$IP/$projectDir" );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment