Failed to run wordpress website on local machine, it gets redirected to live website - wordpress

What I want to do > I need to run a version of my live website on my local machine.
Why I need to run it on local machine I need to edit the website on my local machine and when everything is perfect copy it onto server. So I can easily make changes to the website without scaring of breaking the live website.
Whats the problem > I could run it on my local machine but when I log in to wordpress from localhost it redirects me to the live server.
What steps did I followed > I followed this question, installed mamp and downloaded whole wordpress directory to htdocs directory of mamp, then exported the database on server and imported it to my local server. Ran the server, entered username and password and was redirects to the live server rather than running the website on my local machine.

The code is the same, you just have to edit the database configuration of localhost and change domain to localhost.

tl;dr:
run this to fix it: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
long answer:
Most importantly, the "Home URL" and "Site URL" on the Settings -> General need to be changed. Also, many other URLs are saved into the Database including the domain name. Since some of them might be php-serialized, just search/replace in the database might screw up some things.
The Wordpress Codex has lots of info on moving / clonign a site. Still, the easiest way is the tool from tl;dr above.

Related

Wordpress Add "login/?msg=membershipRequired" to my URL

I have a website (built using wordpress) running in host server. I am trying to run my site in local machine. I install xampp, copy of my sites files, and export/import my database to local apache server.
However, when I am trying to open http://localhost/inj/public (/inj/public contains all wordpress files and folders), the url changes to "http://localhost/inj/public/login/?msg=membershipRequired" and the page shows "Object not found!".
I have changed my site and home url from wp-options table. But the problem is still there.
Any help?
Maybe you are using WooCommerce and have a restriction accidentally added? Have found something about it here: https://docs.woocommerce.com/document/woocommerce-memberships-settings/

Migrating Site To Digital Ocean and having trouble with redirecting to HTTPS

I am migrating my site to digital ocean and I am having an issue with Https. I have moved the directory and the apache2 config file and mysql database. I believe I set everything up correctly but now I want to test it. I have edited my /etc/hosts file with my new ip and sitename.com. However when I try to go to my browser and look to see if the site works it keeps trying to redirect me to the https version of my site.
I have tried going to chrome://net-internals/#hsts and deleting the site but it still redirects to https. How can I test my site without being redirected to the still hosted version of my site?
Thanks!
Aside of the wp_options field, WordPress stores lot's of links 'hard-coded' which all will contain the https. You would need to do a full search and replace on the database, but be aware of serialized stuff. To to safely perform a search and replace you could use a program found on: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Works like a charm.
Another way is by using wpcli if you have commandline access and wpcli is available. From the command line go to your root directory (containing the index.php) and type:
wp search-replace https://www.your-domain.example http://www.your-domain.example
Or type:
wp search-replace https://your-domain.example http://your-domain.example
Based on your setup up course.
Always make a full backup of your database before performing these actions, so you can restore if any problems occur.

Migrating live wordpress to local xampp error

I tried to follow this tutorial on how to migrate a live wordpress site to localhost.
I was semi-successful in that when I open the site locally, it appears to be the exact replica of live site.
However, I encountered two issues.
1) When I try to log into wordpress dashboard on local host, it takes me back to live-server dashboard
2) When I click anywhere on the local site, it takes me back to the live site.
Any advice would be appreciated as I have been trying to migrate the site for weeks now,
Thanks
Most likely the problem is that your database needs updating to reflect the URL change. Via PHPmyadmin, find your database, go to wp_options and update "siteurl" and "home" to reflect your local URL.
A alternative to solve the problem is to export the local database with phpmyadmin in an ascii file and with Notepad++ "Search and replace" fix the urls to show the local host.
Amother alternative it whould be, if you have small site, to usr plugin Duplicator , this produce 2 files an install.pho and a zip. You must take the export from web and then erase tle local and rectreate runing http://localhost/mywp/installer.php. This procedure is going to make everything auto.

wordpress keeps redirecting on locahost when migrating from live server to localhost

For some unknown reason my live wordpress fot blocked, showing following message on each hit
"This site has been temporarily disabled, please try again later."
So, In order to recover data I copied my wordpress site files from domain to my PC. I uploaded the database to phpmyadmin, updated the wp-config.php file for my localhost but every time when I try to hit the site from browser* i.e. "http://localhost:8080/my-site-name/" it keeps me redirecting to the url "http://localhost/my-site-name/"
*my localhost is set up to the port 8080
open database, wp_options table, find row with site_url, home_url.... it's using old value, change them with new address.
Directly copying files from your live WordPress directory and import live database into local will not work as expected.
For this you need to updated all links in you local database with
local server link (Use search in phpmyadmin for domain and replace
with local one.
You may need to updated your .htaccess file according
your local server.
For getting backup from live to local you use
plug-in like Duplicator.
Here is a link duplicator where you will find plugin for backup and restore.It backup both php files and database.so need to import db on local mysql
There is a quick hack to this also. You can create a dummy post on WordPress and publish it. Later you can delete the post. It works for me the most time.

need assistance on my local wordpress

I just finished building my basic website using wordpress and wamp. installation directory is at C:\wamp64\www\wordpress and i'm currently accessing my site at localhost/wordpress
now i have 2 problems:
1. how can i trick my localhost to use http://www.tracking-site.com instead of localhost/wordpress? I tried changing site and wordpress address but all i get is page not found.
after changing my url, i am planning to access my local wordpress (which will now be http://www.tracking-site.com) from another PC.
2a. do i need to copy all the wordpress files to pc#2?
2b. do i need to install wamp to pc#2?
edit: i can skip problem #1 if changing site url is not important. cause my main target here is to access my localhost wordpress from another PC with same LAN. I tried adding tracking-site.com in hosts file to redirect to 127.0.0.1 then in PC#2 added in hosts file 192.168.x.xxx (my ip) then tracking-site.com. not working tho.
I don't want to host it online because my website will only be used internally in my workplace.
This should work, haven't done it in Windows in forever.
Set your site to a different URL, this is probably a bad idea honestly since WP hardcodes a lot of urls like the images, you can get past this by using wp-cli.phar to search and replace in the db but that's not a simple procedure either.
That being said it can be done.
Right click Notepad and open as administrator.
Click Open and change the file type to all files.
open the following file: c:\Windows\System32\Drivers\etc\hosts
Add the following line: 127.0.0.1 www.tracking-site.com
Question 2. Is answered here: How to access my localhost from another PC in LAN?

Resources