1

I have wordpress installed in a sub-directory "www" on my laptop using XAMPP 7.3.0-0 (OS: Ubuntu 18.04 LTS Desktop).

On my laptop, I can access it through http://localhost/www/ or http://192.168.8.200/www/ (after changing WP_HOME and WP_SITEURL in wp-config.php to replace localost with IP address).

The Problem:

When I access http://192.168.8.200/www/ from other devices, it redirects me to http://localhost/www/ saying

This site cannot be reached
localhost refused to connect.

I can access other sub-directories like http://192.168.8.200/ABC/ and http://192.168.8.200/XYZ/ on same server without any issue.

Information that may help to resolve the problem

This is .htaccess file in "www" directory

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /www/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /www/index.php [L]
</IfModule>

# END WordPress

wp-config.php setting:

define( 'WP_HOME', 'http://192.168.8.200/www' );
define( 'WP_SITEURL', 'http://192.168.8.200/www' );
  1. How can I access http://192.168.8.200/www/ from other devices on same network? Any clue...
  2. How can I use my computer name instead of static IP?

Thanks

1

Have a look at the answers here: https://stackoverflow.com/questions/20122583/website-in-wordpress-redirects-to-old-url-after-migration

In particular, I'd check these two: https://stackoverflow.com/a/23873881/1577662

be sure to clear your cache and use this script to replace ALL urls in your database.

https://github.com/interconnectit/Search-Replace-DB

And https://stackoverflow.com/a/41223768/1577662

In case you are using Polylang with a dynamic IP, add define('PLL_CACHE_HOME_URL', false); in your wp-config.php and it will solve all your problems (redirection to the former url)!

Or if you're just setting up, perhaps the easiest path forward may be to start over and use the ip address from the start on a brand new installation.

Re: How can I use my computer name instead of static IP? You would need to have name resolution set up internally, if you run local DNS servers this would work, or you could edit the local hosts files on the servers that need to access the site.

  • 1
    Thanks @user16081 , clearing browser cache resolved the issue. – Qaisar Feroz Feb 24 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.