Wordpress wp-admin Redirects to EC2 domain - wordpress

I'm trying to install my wordpress to AWS EC2.
I created my EC2 instance and send files to that. (and instance domain has ben blablabla.eu-west-1.compute.amazonaws.com)
I used aws certificate manager for my domain.
I used cloudfront for using ssl certificate and; values are:
origin: blablabla.eu-west-1.compute.amazonaws.com
cnames: mysite.com
But when I connect to mysite.com/wp-admin it redirects me to blablabla.eu-west-1.compute.amazonaws.com.
Yes, I tried to change siteurl and home variables. And it doesnt make any changes.
And other hand; when I try to connect with "mysite.com" it converts all files to http (buy when I try to connect wit blabla.eu... all files are https)
What should I make?

Can be various things but I assume (based on previous experience) that some strings in Wordpress still contain mysite.com.
Before you go any further, it's worth to note that you can migrate your domain mysite.com to cloudfront/ec2/acm.
But if you want to just switch to another domain what I usually do is that I install wordpress CLI https://wp-cli.org/ and then I run wp-cli search-replace mysite.com blablabla.eu-west-1.compute.amazonaws.com --all-tables. It's good to have a backup just in case something went wrong, but this worked for me multiple times without any issues.

Related

Azure Bitnami WordPress: Cannot get third-party SSL cert to be picked up by server

I'm following this documentation to finalize SSL configuration, using a third-party-provided certificate, but having issues: https://docs.bitnami.com/azure/apps/wordpress/administration/enable-https-ssl-apache/
I've added the following entries to /opt/bitnami/apache/conf/bitnami/bitnami-ssl.conf, in order to replace the working LetsEncrypt certificates with my new ones. (domain names are obviously obfuscated in the file screenshot, but it does match filenames in the directory)
Here is a screenshot showing the directory where the certificates are held. Permissions look correct, I believe.
After getting the configuration in place, I restarted all Bitnami services, and even Apache explicitly, but this new cert doesn't seem to get picked up by the server/browser.
Did I miss something? Perplexed here....
Bitnami Engineer here,
You are editing the SSL certificates to use for the default VirtualHost of Apache. However, the WordPress app also has another VirtualHost for it. In order to use the new SSL certificates when accessing WordPress, you will need to edit the /opt/bitnami/apache/conf/vhosts/wordpress-https-vhost.conf file.
Note: I'll notify the Bitnami documentation team to update the documentation accordingly.

How to fix a cloned AMI with another domain SSL certificate on it for Wordpress on AWS?

In 2018 I made a Wordpress site by using a Bitnami AMI for a AWS EC2. Fine developed a site and created another custom AMI of the finalized Wordpress site. This was for domain X.
Now in 2020 I wanted to duplicate that website by using this custom AMI for domain Y. I have created an EC2 based on that custom AMI and instance went online without problems.
The problem is now that I can not reach the site by its url, I got blocked by "This connection is invalid", I also see that certificate is still based on the domain of 2018, thus is invalid. So I think that the issue is caused by the SSL configuration based on domain X while it is iinitiated for domain Y. But since I am not able to reach the site neither the admin panel, I am wondering how I can disable the SSL/HTTPS enforcement so that I can reach the site and admin panel?
I do have access to SSH, so probably I should be able to do something from there? But totally not known with that type OS and usage via SSH.
Bitnami Engineer here,
As you created a snapshot of the 2018 instance, the new instance has the same configuration you had at that time. Please check the following items so you can update the certificates and the app's configuration to work properly using your new domain name:
The certificates are configured in the /opt/bitnami/apache2/conf folder by default. You probably substituted the ones we include with valid certificate files for your domain in 2018. You will need to substitute the server.crt and server.key now with the new ones.
https://docs.bitnami.com/aws/apps/wordpress/administration/enable-https-ssl-apache/
Regarding the WordPress configuration, we have configuration tool that takes care of updating the domain name in the database. Can you take a look at this guide?
https://docs.bitnami.com/aws/faq/configuration/configure-custom-domain/
You will basically need to run sudo /opt/bitnami/apps/wordpress/bnconfig --machine_hostname my-new-domain.com.
I also suggest you check the WordPress' configuration file (/opt/bitnami/apps/wordpress/htdocs/wp-config.php) to see if you edited the WP_HOME and WP_SITE parameters there.

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.

Unable to successfully change wordpress site URL

I'm trying to set up Wordpress with Multisite, and the first thing I'm trying to do after getting the Bitnami AMI running on an EC2 host is assign an Elastic IP. However, as soon as I assign this, I'm unable to get to my Wordpress login page due to redirect issues.
When I try to go to my new URL of http://ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com, I get redirected to http://ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com/wp-signup.php?new=ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com, with a redirect loop error shown by my browser. (The IP address, noted with x's, is the same in all 3 cases).
Also, as expected, my apache access_log spits out 20 of the following lines when I try to access my site:
[05/Jun/2016:19:56:41 +0000] "GET /wp-signup.php?new=ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com HTTP/1.1" 302 -
Things that do work
Before I assign the Elastic IP, I can access the Wordpress site from http://ec2-yy-yy-yy-yy.us-west-2.compute.amazonaws.com, as long as I dont make any changes to the site URL after spinning up the EC2 instance with the Bitnami Wordpress AMI.
After assigning the Elastic IP, I can SSH into the EC2 instance with both the new IP and the corresponding *.compute.amazonaws.com hostname.
Things I tried
Following these steps, I've...
Updated DOMAIN_CURRENT_SITE in my wp-config.php, as well as updated site_url and home to match the new hostname.
Added WP_HOME and WP_SITEURL to my wp-config.php
Added the RELOCATE flag
None of those appear to fix the redirection issue.
Aha - I found another link that states migrating a Multisite setup is a bit more involved, and requires searching through all database tables for any references to the old hostname:
http://codex.wordpress.org/Moving_WordPress
Searching through all the tables in phpmyadmin... I did find some more references! After updating all of these, I can now get to my site using the new Elastic IP.
Bitnami stacks come with a tool to automatically configure the machine IP of the installation. In the case of WordPress, you just need to SSH into your machine and execute the following command:
sudo /opt/bitnami/apps/wordpress/bnconfig --machine_hostname NEW_DOMAIN
Hope it helps.

Subdomains with Wordpress multisite and Amazon EC2

I have a a WordPress multisite install (using subdomains, not subfolders) running on EC2 (with Cloudflare for DNS). It is working good.
I am starting a new project that I want to setup a subdoamin for that is not using the multisite install. I have been trying for a few days to get it to work, but i cannot get it to stop sending trafic to wordpress (which is telling me there is not site set up (I hae set nothing up in wordpress as this project has its own site / code that I want to keep seperate)
What am I doing wrong?
Thank you?
After quite a while of banging my head agenst the wall I figgured it out.
How I got it to work was I went into the Apache config file (httpd.conf) and changed the server name to a fake address, then wet into vhosts.conf and created a virtual host for every site on the server, including the main one (that had been listed in the main conf) and the wildcard (for multisite).
I made sure the wildcard was listed LAST. After restarting the server it worded like a charm.

Resources