I am developing a site using wordpress, MySQL and Xampp. The current url is like localhost/wordpress/sitename
.
How can I change the localhost to an ip address to get the site working on other computers on the same network?
Leave a Reply
You must be logged in to post a comment.
First Change url in “wp-option” table in site_url and home_url.
then change folder name in .htaccess file. and then change database name in wp-config.php file
In my scenario I found that intranet users weren’t receiving the images and other resources (stylesheets) when connecting to my locally hosted wordpress site by url. The problem was that the urls for those resources were being emitted as localhost, which of course wasn’t useful to their machine.
The general solution is to update the
WordPress Address
andSite Address
on the General Settings tab in the WordPress dashboard with your ip address rather than the default of localhost, then everything will be emitted relative to that.In my case I wasn’t able to edit those directly for configuration reasons I haven’t resolved. I found the solution on the WordPress site under the
Relocate
subtopic on “Changing the site URL”. It’s simple.Near the end of the wp-config.php file, just before the line
add the following
Then navigate to your site using the url rather than localhost and the setting s will be updated. In a local network situation where your url is changing frequently you could just leave the switch set to true, but on a production server it would be a security risk, and you should revert the setting to ‘false’ or remove the statement promptly.
put this statements into wp-config.php :
You put your IP address allocated by the network’s DHCP server(if it exists) instead of ‘localhost’ it should work. else just put your ip address form the other computers connected to the network.
Eg. If your IP address turns out to be 127.23.45.66
You should enter this in the address bar of the other comps
127.23.45.66/wordpress/sitename
You should change the site URL in your WordPress settings to your IP else WordPress will always redirect to what is in the settings.
after you access your site by 127.23.45.66/wordpress/sitename on any browser in your network including your own device.
So, apparently, WordPress had saved that
Other_IP
(the old IP) in the database. Therefore, the solution was to change thatOther_IP
to the current IP (IP_of_Server
) in the database, in our case, MySQL.So, now yes, we are going to solve it in one step.
To do this, we must first enter the MySQL database engine or any other, locate ourselves in the specific WordPress database and update the corresponding fields, which are:
site_url
andhome
, which are inside thewp_options
table, by default,or the equivalent according to the table prefix that you have left for the WordPress installation. We are going to illustrate with a specific example of our installation, how to solve the problem; You must adapt it to your case.To connect to mysql use following command:
In case you know the name of your
wp_options
table, you can skip this step. Go to Update recordsTo find the table name, follow next step:
Once you have access to Mysql, search for databases with command:
Locate your wordpress database and use following commando to start using the database:
Once you are using the wordpress database, you should list the tables using the command:
The command should return with all tables on you wordpress database, in which you can fin your
[prefix]_options
(wp_options
by default)Update records
Once you know the table, you just need to update 2 records with the following commands:
If your wordpress is not on you root folder of your server, you need to set the route.
http://[IP_of_Server]/route
, otherwise, it will not work correctly.