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

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.

Related

ERR_SSL_PROTOCOL_ERROR after migrating WordPress site to another site - attempting to create staging environment

I have a site hosted on 1&1 Ionos hosting. Purchased an SSL for the site from 1&1 Ionos as well. So let's say https://www.business.com/ is what I have. Then I have another another site say http://www.mycompany.com/ hosted at the same place - still waiting for my business SSL to be approved hence the http.
So I exported the database from business.com using plugin WP Migrated DB - setting the new URL and actual filepath.
Then I imported the database into a new database for my staging environment to be hosted at http://www.mycompany.com/clients/business.
I copied ALL the wordpress files for the site http://www.business.com/ into http://www.mycompany.com/clients/business exactly except I changed wp_config.php file to reflect the new database details. i.e username, database, location and password.
So I expected http://www.mycompany.com/clients/business to be a complete replica of the original https://www.business.com/. But when I browse to http://www.mycompany.com/clients/business I get the following error:
This site can’t provide a secure connection mycompany.com sent an invalid response.
Try running Windows Network Diagnostics.
ERR_SSL_PROTOCOL_ERROR
I can't even login to the admin panel of http://www.mycompany.com/clients/business/wp-admin
Is what I tried even possible and if it is please tell me what I did wrong and how to fix it. I'd like to create a staging environment to test new themes and plugins before implementing on live environment. Critical to my original site is the aMember plugin which manages all the membership registration info. I've deleted the Really Simple SSL plugin folder from WP-Content/Plugins folder but the error remains.
Thanks in advance for any and all help and advice!
Step 1:
Check your .htaccess for rules enforcing https
Step 2:
Did you replace all links in the database? If not, you must search and replace all links from https://www.business.com/ to http://www.mycompany.com/
You can use a tool from: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/comment-page-4/
Or just use command line wpcli (wp search-replace https://www.business.com http://www.mycompany.com
Step 3:
Open the new 'http://www.mycompany.com/' in a incognito tab. Browser caching might still redirect you to https.

How to change Wordpress site URL when migrating site to/from another server?

I have a Wordpress site that is currently running at www.example.com, hosted on a shared hosting environment. I am moving it off of this shared server, onto a cloud VM platform where I will be running a web server to host the site.
So far, I have copied the wordpress directory into /var/www/ on the new server, and configured Apache to point to /var/www/wordpress. I also created a copy of the Wordpress database from the old server, and imported it into mysql on the new server.
Before transferring the DNS for www.example.com to point to the new server, I want to make some changes to the copy of the site on the new server, using the IP address of the new server to access the new local copy, instead of the domain name www.example.com (I want to keep the original site running on the old server in the meantime, so that there is no downtime).
But after copying everything over, I cannot access the site on the new server, because the site URL is still set to www.example.com internally, so when I type in http://215.15.7.100, I just get redirected instantly to www.example.com (the existing live site on the shared server).
I have tried to follow the Wordpress instructions at Changing the Site URL, but they are incorrect or missing something. I did as suggested there and added the following to my wp-config.php:
define('WP_HOME','http://215.15.7.100');
define('WP_SITEURL','http://215.15.7.100');
... but this had no effect. It still automatically redirects me to example.com.
I also tried updating the wp_options table in the MySQL database, to change the siteurl and home settings. To do this, I ran the following queries:
update wp_options set option_value = 'http://215.15.7.100' WHERE option_name = 'home';
update wp_options set option_value = 'http://215.15.7.100' WHERE option_name = 'site_url';
... the fields were updated correctly in the database, but again, it has no effect and the site still redirects me instead of using this value.
The documentation mentions a variety of other suggested methods, with no discussion of when each is desirable to use. But at this point, I don't want to keep randomly trying things that don't work, because I don't want to mess things up.
How do I change the site URL so that it won't redirect me, and will instead just use the server IP as the base URL?
In this case OP needed to clear his own cache, so do a hard refresh or reset your browser first, then any caching plugin you may be using.
If you still are having issues with something like this, go through the following steps.
Go into phpmyadmin (make sure you are looking at the right database!), and double-check that the entries in wp_options (you might have other prefix), siteurl and home cells say what you want them to say. If no, you can edit them straight through the phpmyadmin gui, instead of using SQL commands.
Make sure your wp-config.php file on FTP/file server is hooked up to the correct database, with the correct user and password. Also check that the prefix matches the prefix of the database.
If you have access to the backend of Wordpress, refresh your permalinks, by switching forth and back to a new url structure, and back to your usual one.
As a last effort, try backing up all your plugins locally, and then deleting them from the WP install, in case you have some sort of redirect on top of the usual base-wordpress install.
The next steps are to check your theme or theme settings, or to start looking at DNS-redirects set up with your domain-host but that is a big and hairy world, and a bit outside the scope of your question.

Changing URL Wordpress- still not working despite checking/editing database

As much as may sound like a broken record - I changed the URLs on my WP site, and now I get a 404.
What I wanted to do:
Change site URL from www.SiteA.com to www.SiteB.com
All WP files were at the time in another directory in the same hosting account. I needed them in the root directory, accessible by www.SiteB.com
What I did:
Backed up locally and remotely - Database and files.
Edited URL's through dashboard on WP - got a login error afterward, but seemed to do it anyway.
Moed ALL old site files from root to backup folder.
Moed ALL wordpress files from original directory to root directory.
Then I got a 404 error and was unable to access WP-admin or login through the new or old URL.
What I tried to fix the issue:
Noticed http should be https - changed this in 'options' within phpmyadmin, both at 'siteurl' and in 'home'.
Still 404
Then I tried defining the db_name in the wp-config file.
Still 404
Then I gae up, changed the URL's back using myphpadmin, and moed the filed back to their original directory. Now I can login to WP as usual and eerything is fine.
Why can't I access the site when I moe it into the root directory - I thought I had all the steps right!
Thanks in adance for any help
oh..and apologies, my keyboard is missing a few keys :(
Wordpress stores url/permalinks on database field values as well, changing only the configuration files will not be enough.
I am pretty sure there are other options, on my case i use often perform Wordpress website migrations, and the following tool becomes really handy when search and replacing domains on the database records.
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Hope it helps.
Jose
This happened to be an SSL issue where the host for our SSL certificate was conflicting with the stylesheet somehow. 0_o

wordpress admin redirect loop

I've got a copy of our wordpress instance running inside a Docker container.
Our live instance works well but inside the docker container, I do get a redirect-loop as soon as I try to get access to wp-admin.
I've disabled all plugins, I've cleared my cache and so on but nothing worked so far.
OS is debian, similar to our live system. When I get the redirect-loop, there's no information written in my apache error.log-file.
Oh and this instance is accessible by using a subdomain. I had to rewrite all "www.domain.com" to "sub.domain.com".
If I can provide you with any informations to solve my problem just ask. I have absolutely no idea where to start.
Paddaels
Seems like you missed some records in the database. The best approach is to use a tool like https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
If you download this free tool and upload to your server then it does a batch find-and-replace across every single table in your Wordpress database.
So, for example, replace http://www.example.com with http://sub.example.com
You can do a dry run and it will show you all the replaces that it will make. Once you're happy then click the "live run" button and all the changes are made.
I use this tool all the time when I am moving a site from my local machine to the live server. I also use the exact same approach when migrating a site from http to https

moving WordPress over to domain, after working on it locally through MAMP

I've finished the styling changes on WordPress and I'm ready to move it from MAMP to my domain.
Will this involve any changes to the WordPress files or can I just drag it over to my new domain once I purchased it?
The main start you must make is update your wp-config.php
define('WP_HOME','http://www.mynewdomain.com');
define('WP_SITEURL','http://www.mynewdomain.com');
That way wordpress knows what domain it MUST run from.
The reason you do that is because without this you may not be able to access admin, login, etc etc.
When this is working and you have logged in, go to wp-admin and go to your permalink settings.
Make a NOTE of your settings, then change them to default (and woocommerce settings etc).
Go to your home page and a few others, and notice how messed up your urls look :)
Now go back to permalink settings and restore them (the point of this is to make sure your .htaccess file that wordpress depends upon is set correctly)
Finally, have a look at https://github.com/veloper/WordPress-Domain-Changer to change your sql etc if needed.
note this method is very handy for developers so you just update your wp-config.php for localhost or development or production (not for testing purposes, don't use your local pc. copy it all up to a subdirectory of your hosting partner e.g. http://www.mynewdomain.com/mytestarea. Make sure you use a COPY of the mysql database (never point both to the same database). You now can test on the hosting platform without disturbing the live site or your development causing issues to other people.
It's been a long while for me personally, but you'll want to change the SiteURL via the options menu in wp-admin.
Otherwise, just make sure your MySQL database is exported over, your credentials and user permissions are all setup and those work too.
If you still have problems:
https://codex.wordpress.org/Changing_The_Site_URL
https://codex.wordpress.org/Moving_WordPress
The database has to be updated. What always works for me is that I export the database from phpMyAdmin or MySQL (using mysqldump) and open the exported .sql-file with a text editor, like Sublime Text.
Now you want to find any occurence of your previous URL. Let's say on your dev machine the URL to the index of your Wordpress site is http://localhost:8080/wordpress and you want it to be on a website under https://domain.com you simply do a Find & Replace using that and replace everything with https://domain.com.
For older Wordpress versions you have to update the .htaccess files if you have custom URL's.
You have to make a search replace in your database and replace your local domain ( test.lo ) with the live domain ( test.com ).
To do this you can use the script from here: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Add the searchreplacedb2.php file in your route folder and the access test.lo/searchreplacedb2.php and follow the steps there. This will replace your local domain with your live one everywhere in the database.
You can't make a simple search-replace because the local domain might be serialized in some fields in the database, and a simple search-replace will not replace those.

Resources