Making a WordPress site accesible from inside LAN and outside it
the main issue is because wordpress use the server address from database.
WordPress uses the root url from the option named home
and siteurl
so if you try access WordPress outside their computer it might get the incorrect path for css and javascript.
you need to change the options under setting
-> general
and fill in the WordPress Address (URL)
and the Site address (URL)
with your server IP
if you want to get correct path without doing redirect, you can defining the dynamic root url under wp-config.php
add this script below the define('ABSPATH', dirname(__FILE__) . '/');
/** * get home url from absolute path * @return string url to main site * hello@lafif.me */function get_dynamic_home_url(){ $base_dir = ABSPATH; // Absolute path $doc_root = preg_replace("!${_SERVER['SCRIPT_NAME']}$!", '', $_SERVER['SCRIPT_FILENAME']); $base_url = preg_replace("!^${doc_root}!", '', $base_dir); $protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https'; $port = $_SERVER['SERVER_PORT']; $disp_port = ($protocol == 'http' && $port == 80 || $protocol == 'https' && $port == 443) ? '' : ":$port"; $domain = $_SERVER['SERVER_NAME']; $home_url = "${protocol}://${domain}${disp_port}${base_url}"; return $home_url;}$url = get_dynamic_home_url();define('WP_SITEURL', $url);define('WP_HOME', $url);
Have a look at the Relative URL WordPress plugin. Even though the plugin is made for accessing the page via IP from local network, the effect should stay the same. (Because the main problem is the changing URL)
Relative URL applies wp_make_link_relative function to links (posts, categories, pages and etc.) to convert them to relative URLs. Useful for developers when debugging local WordPress instance on a mobile device.
http://localhost:8080/wp/2012/09/01/hello-world/
will be converted to /wp/2012/09/01/hello-world/
http://localhost:8080/wp/wp-content/themes/twentyeleven/style.css
will be converted to /wp/wp-content/themes/twentyeleven/style.css
Then after activating this plugin, you can simply access your local instance using http://192.168.0.1:8080/wp/ on your iPad or other mobile devices without having styles and navigation issue.