How to change a localhost url to ip in wordpress? - wordpress

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?

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 and Site 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
/* That's all, stop editing! Happy blogging. */
add the following
define('RELOCATE',true);
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 :
if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1' || $_SERVER['REMOTE_ADDR'] == '::1') {
define('WP_SITEURL', 'http://localhost/wordpress/sitename/');
define('WP_HOME' , 'http://localhost/wordpress/sitename');
} else if (strpos($_SERVER['REMOTE_ADDR'],'192.168.1.') !== false) {
//local network: see ifconfig
define('WP_SITEURL', 'http://192.168.1.57/wordpress/sitename/');
define('WP_HOME' , 'http://192.168.1.57/wordpress/sitename');
}

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.

Related

How to access website using hostname instead of ip address?

I am working on a wordpress website and I'm unable to access my website using the host-name. [However, I'm able to access my website through the ip address. For example, when I enter 10.20.0.18, I'm directed to 10.20.0.18/wp-admin/plugins.php]
I am new to hosting and I was just able to update my hosts file and properly link the ip address to hostname by reading through some articles.
I also checked these links are correct using ping command.
For example, my hosts file looks something like this,
#Host file starts here
127.0.0.1 localhost
10.20.0.18 www.webserver.abc.com
66.155.40.202 api.wordpress.org
#End of host file
Now, when I try to access the website using hostname through my web browser, I get this error.
This site can’t be reached www.webserver.abc’s server IP address could not be found.
I am not sure where I am going wrong, or do I need to make some more changes in other files?

Local host WordPress website URL changed not able to revert back

I wanted to test my localhost WordPress website on a mobile device on my local network, So I changed my website URL and Site URL to http://192.168.1.3.8888 (wifi IP: Mamp apache port) previously it was http://localhost:8888/wordpress, Now I am unable to access the site from own pc with the new or the old URL.
I think in the new URL I used a '.' instead of a ': ' between the wifi IP and Port number can somebody help to revert the changes I have made or make this work.
Thanks!
Open phpmyadmin or another mysql db manager
Browse your website's wp_options table.
You will see 2 related rows there called "siteurl", and "home".
Fix them to correct address.
That's all.
You can replace or export data using Wp Migrate DB.
Easy to replace any url in your current database without lose any data or serialization issue.
Changing the Site URL multiple ways.
net::ERR_CONNECTION_REFUSED
Change your post 8888 to 80 in site & home url.
Its best to run of port 80 though instead of 8888.

How do I point my domain to my website that's hosted on an AWS EC2?

The registrar for my domain is godaddy, I go to their DNS records section and I changed the A name to the elastic IP associated with my instance. Now when I type my domain in the browser, my website appears! However, it forwards it to the IP of my server.
Things I've tried (whether logical or not):
I'm using wordpress multsite so I changed the DOMAIN_CURRENT_SITE in wp-config.php to my new domain. No luck. Reverted.
I changed the 'site_url' and 'home' in my database to point to my domain. No luck. Tried one at a time etc. Reverted.
Changed ServerName to my new domain in httpd.conf (apache).
sudo hostname www.... (don't know what that does)
So I'd like to simply have my website open without it showing the IP in the address bar. Can someone help?
Thanks
EDIT:
Here's the DNS page of godaddy, I've blanked out the ip in the A records, but it's just the ip of my server.
First you need to set Custom NS in godaddy with AWS dedicated IPs then set them as DNS. If you are using Linux instance with cPanel then just add the domain in cpanel's addon-domain.
If you are using Windows instance then you should configure IIS.

Amazon Web Services - EC2: How do I stop my WordPress site showing the ip address as the domain?

I am close to tearing my hair out on this issue as I just cannot seem to get my Wordpress site to not read the Amaazon Public IP address.
I have a domain name in GoDaddy and have changed a host record so that my domain name "http://example.com" redirects to "http://0.0.0.0".
However once this page loads, the url quickly changes back to the Public IP address.
I have tried changing the Site URL in the Wordpress Settings but this just breaks the site and does not allow me to log in.
What is it I am doing wrong? I just cant figure it out. I just want the domain name from goDaddy to appear as the URL.
Thanks.
First of all attach the Elastic IP to your EC2 Instance so it wont change public IP after you shutdown and restart your machine. Make A Record in your Godaddy DNS Record File that points to the elastic IP.
You have not changed the base URL of your wordpress thats why it is still redirecting to the old Base URL. Connect to your EC2 instance and edit wp-config.php add the following line of code
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');

Change ip issue

I have added a new floating ip to my VPS (digital ocean - CentOs7) and I have added this in WHM and I have bind this ip to a domain. I have point domain's DNS correctly to my new ip.
But when I go in my domain I view this:
error page WHM cPanel
Please try to access your IP through browser and check which page are you getting. if you correctly setup your domain on that IP, then you will your site home page at : http://IP
Also try to rebuild httpd configuration file on your server through following command
/scripts/rebuildhttpdconf

Resources