- Newest
- Most votes
- Most comments
The issue you're experiencing with your WordPress site on AWS Lightsail, where image URLs change from your domain name to the static IP address after a day or two, is a known problem that can occur for various reasons. This causes images to break due to mixed content and SSL certificate issues.
Several factors could be contributing to this problem:
-
WordPress and site URL settings: Ensure that both the WordPress Address (URL) and Site Address (URL) in your WordPress General Settings are correctly set to your domain name (www.gombosmez.hu).
-
wp-config.php file: Check if the WP_SITEURL and WP_HOME constants are correctly defined with your domain name. If they're not present, you may need to add them.
-
Database entries: There might be a script or cron job running that's reverting the changes in your database, causing the URLs to switch back to the IP address.
-
Plugins or theme functions: Some plugins or theme functions might be overriding your URL settings.
-
.htaccess file: Ensure it's correctly configured and doesn't contain any problematic redirects.
To resolve this issue, you can try the following steps:
- Double-check your WordPress and site URL settings in the admin panel.
- Verify the wp-config.php file for correct domain settings.
- Use a search and replace plugin to find and replace all instances of the static IP with your domain name in the database.
- Clear your browser cache and local DNS cache.
- Review your installed plugins and theme for any that might be causing this behavior.
- Check your .htaccess file for any unusual redirects.
If the problem persists after trying these solutions, you may need to investigate further or seek assistance from AWS support to identify the root cause of the automatic reversion. Always remember to backup your site before making any significant changes to your WordPress installation or database.
Sources
Domain is changing to Static IP automatically | AWS re:Post
Static IP address being used instead of domain - getting SSL error | AWS re:Post
My website is loading some images from ip instead of domain - AWS Lightsail | AWS re:Post
After replacing the rows in wp-config.php file :
define( 'WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] . '/' ); define( 'WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] . '/' );
to
define( 'WP_HOME', 'https://gombosmez.hu/' ); define( 'WP_SITEURL', 'https://gombosmez.hu/' );
and restart the server, AND repost the page in WP Elementor, the issue is SOLVED. Downloading pictures correctly even after 2 weeks.
Thanks for the hints!
answered 2 years ago

wordpress address and Site Address both are the same (gombosmez.hu).
wp-config.php contains these rows: if ( defined( 'WP_CLI' ) ) { $_SERVER['HTTP_HOST'] = '127.0.0.1'; } define( 'WP_HOME', 'https://' . $_SERVER['HTTP_HOST'] . '/' ); define( 'WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST'] . '/' ); after changed it to my domain https://gombosmez.hu, it is still wrong, even after restarting the resource.
I tried to search in database with a plugin, but didn't find the IP address there! So I cannot change it. 4, I reduced the plugins to absolute minimum, still have the problem.
I think .htaccess file don't have any problem: bitnami@ip-172-26-11-24:~$ cat /opt/bitnami/wordpress/.htaccess
BEGIN WordPress
A
BEGIN WordPressés azEND WordPresssorok közötti tartalom dinamikusan lett létrehozva, és csak WordPress szűrők módosíthatják. E kettő sor közötti bármilyen kézi módosítás el fog veszni. <IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
END WordPress