Support » Fixing WordPress » Yet another too many redirects: WP 5.3.2 on AWS VM

  • Hi,
    I have a AWS Ubuntu VM with WordPress 5.3.2 installed, the static IP is 52.73.240.32

    I registered the domain gopotatomusic.com with Google Domains using this static IP.

    I can connect to the web site with http://gopotatomusic.com but after that the URL bar shows the static IP.

    In the WordPress settings, “WordPress Address (URL)” and “Site Address (URL)” are both set to the IP address and grayed out.

    I see a lot of suggestions about changing WP_SITEURL and WP_HOME the file wp-config.php under htdocs.

    I can use putty to login to the VM and view the file — these are the current values for these settings:

    define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/');
    define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/');

    If I change to

    define('WP_SITEURL', 'http://gopotatomusic.com/');
    define('WP_HOME', 'http://gopotatomusic.com/');

    The web page immediately stops working with a “too many redirects error” both on Chrome/Windows and Firefox/Centos.

    I also see posts that mention the .htaccess file, here are the contents:

    # BEGIN WordPress
    # The directives (lines) between <code>BEGIN WordPress</code> and <code>END WordPress</code> are
    # dynamically generated, and should only be modified via WordPress filters.
    # Any changes to the directives between these markers will be overwritten.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    I’ve looked at the logs in opt/bitnami/apache2/logs but don’t see much.

    Any help appreciated!
    Thanks
    Geoff

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • you don’t have to insert a final slash in the define value for WP_HOME and WP_SITEURL.
    Name-based (virtual) hosts configure via server_name and the host header is likely that your server has no support for the HOST header.
    for the moment you have to understand why the redirect, the secondary problems can be resolved later, the constants temporarily overwrite the values of your database.

    I believe your wordpress side is ok. What I would look at is your domain name configuration.

    It seems that your domain name is redirecting to the IP – 52.73.240.32.

    I see that your domain name’s DNS is pointing to Google. If you want to use Google’s DNS, then create A record to point to 52.73.240.32. This should work.

    Alternatively, you can make it work is to create DNS zone in your AWS and then point your domain’s nameserver to your new DNS zone. After that, then create A record to point to 52.73.240.32. This is the step – https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-tutorial-launching-and-configuring-wordpress#tutorial-launching-and-configuring-wordpress-creating-a-dns-zone

    Hope this helps.

    Thanks. I have done some more investigating. When I change wp-config.php to point to the domain name, and check it with curl (to avoid any browser questions),
    I see that http://gopotatomusic.com redirects to http://52.73.240.32 but also that http://52.73.240.32 redirects to http://gopotatomusic.com, see below.

    So that is my redirect loop.

    Now I think the issue is with the grayed-out URLs in the WP Settings page that point to the IP address. Why are they grayed out? Is there a way to change them?

    Thanks
    Geoff

    bitnami@www:/opt/bitnami/apps/wordpress/htdocs$ curl http://gopotatomusic.com |
    
    <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
    <TITLE>301 Moved</TITLE></HEAD><BODY>
    <H1>301 Moved</H1>
    The document has moved
    <A HREF="http://52.73.240.32/">here</A>.
    </BODY></HTML>
    bitnami@www:/opt/bitnami/apps/wordpress/htdocs$ curl http://gopotatomusic.com
    <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
    <TITLE>301 Moved</TITLE></HEAD><BODY>
    <H1>301 Moved</H1>
    The document has moved
    <A HREF="http://52.73.240.32/">here</A>.
    </BODY></HTML>
    
    bitnami@www:/opt/bitnami/apps/wordpress/htdocs$ curl -v http://52.73.240.32
    * Rebuilt URL to: http://52.73.240.32/
    *   Trying 52.73.240.32...
    * Connected to 52.73.240.32 (52.73.240.32) port 80 (#0)
    > GET / HTTP/1.1
    > Host: 52.73.240.32
    > User-Agent: curl/7.45.0
    > Accept: */*
    >
    < HTTP/1.1 301 Moved Permanently
    < Date: Sun, 12 Jan 2020 16:25:57 GMT
    < Server: Apache
    < X-Powered-By: PHP/7.3.7
    < Expires: Thu, 19 Nov 1981 08:52:00 GMT
    < Cache-Control: no-store, no-cache, must-revalidate
    < Pragma: no-cache
    < X-Redirect-By: WordPress
    < Set-Cookie: PHPSESSID=ke0aok0jtnk64i3nk9u1us3rj5; path=/
    < X-Frame-Options: SAMEORIGIN
    < Vary: Cookie
    < Location: http://gopotatomusic.com/
    < Content-Length: 0
    < Content-Type: text/html; charset=UTF-8
    <
    * Connection #0 to host 52.73.240.32 left intact

    Looks like this is a bitnami issue, I will try posting there.
    Thanks
    Geoff

    WordPress redirects if it is not your WP_HOME if you define this constant WordPress does not redirect. (if you have configured the virtual host with the value of a HOST: gopotatomusic.com header).
    I hope, this help

    define( 'WP_HOME', 'http://gopotatomusic.com');
    define( 'WP_SITEURL', 'http://gopotatomusic.com');

    Example Virtual host https://www.ostechnix.com/configure-apache-virtual-hosts-ubuntu-part-1/

    Resolved == it was my DNS settings, I had set up Google Domains to forward the domain name to the IP address, instead of creating an A record.
    Thanks
    Geoff

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.