Wordpress side "redirected you too many times."

Keywords: WordPress - Google Cloud Platform - Technical issue - Connectivity (SSH/FTP)
Description:
I need help with my WordPress site that I can’t access anymore. I haven’t touched it in months and all of a sudden it stopped working. I thought I was out of space on my VM so I added space to that but it’s still not working. The error message I’m getting is:

“This page isn’t working www.veggovendy.com redirected you too many times. Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS”

I’ve restarted the apache and did a bunch of changes in the wp-config.php that i read in other forums but nothings working.

I’m not the most technical so please explain like you would to a 5-year-old

Hi @veggovendy,

It seems that Cloudflare is what is creating that redirection loop

HTTP/2 301
date: Wed, 18 Nov 2020 10:32:14 GMT
content-type: text/html; charset=iso-8859-1
set-cookie: __cfduid=df6fdbecee0e3af37b9133a3dc76210d51605695534; expires=Fri, 18-Dec-20 10:32:14 GMT; path=/; domain=.veggovendy.com; HttpOnly; SameSite=Lax; Secure
x-frame-options: SAMEORIGIN
location: https://www.veggovendy.com/
cf-cache-status: DYNAMIC
cf-request-id: 067c828ea600000e3624340000000001
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=gpQbwyiRh4iObS57T%2F6bA9qoz5W2gMqZE27LsyZWQueBqxmaahXC%2Fdwa4ye%2F7UdinsXuq%2BrPMLrgDfEHu%2FOVsotfCy2uCunQijNet1pmd5OCyag%3D"}],"group":"cf-nel","max_age":604800}
nel: {"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 5f4106c43a0b0e36-IAD

I don’t know if you have configured any other redirection in Apache so that’s why Cloudflare perform those redirections. Can you confirm this?

We have a Support Tool that will gather relevant information for us to analyze your configuration and logs. Could you please execute it on the machine where the stack is running by following the steps described in the guide below?

Please note that you need to paste the code ID that is shown at the end.

Hello,
When my website stopped working so saw I that I didn’t have apache running so I started it and I don’t know if it’s why? Am not supposed to have apache running?

I’m trying to run the support tool but I can’t put it in any directory. I’m trying to put it in /opt/bitnami but I get this: Warning: The path does not seem to contain a valid Bitnami installation! Make
sure you have proper access rights.
Press [Enter] to continue:

Hi @veggovendy,

Yes, of course. If Apache is not running, Cloudflare won’t be able to access the information.

This is weird, can you run this command?

ls -la /opt/bitnami

Please ensure you set /opt/bitnami as the installation directory when running the support tool. If you continue getting the same error, please run these commands and share the output here:

sudo ls -la /opt/bitnami/apache2/conf
sudo cat /opt/bitnami/apache2/conf/bitnami/bitnami.conf
sudo cat /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf
sudo cat /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf
sudo cat /opt/bitnami/apps/wordpress/conf/httpd-prefix.conf
sudo cat /opt/bitnami/apps/wordpress/conf/httpd-vhosts.conf
sudo cat /opt/bitnami/apps/wordpress/conf/httpd-app.conf
sudo cat /opt/bitnami/apps/wordpress/htdocs/wp-config.php | grep "WP_HOME\|WP_SITEURL"

Thanks

When I run ls -la /opt/bitnami this happens:

total 3496
drwxr-xr-x 19 root    root       4096 Nov 15 19:14 .
drwxr-xr-x  5 root    root       4096 Mar  9  2020 ..
drwxr-xr-x 14 root    root       4096 Nov 14  2019 apache2
drwxr-xr-x  5 root    root       4096 Nov 14  2019 apps
drwxr-xr-x  2 root    root       4096 Nov 14  2019 bncert
lrwxrwxrwx  1 root    root         46 Nov 14  2019 bncert-tool -> /opt/bitnami/bncert/bncert-0.5.1-linux-x64.run
drwxr-xr-x  2 root    root       4096 Nov 14  2019 bnhelper
lrwxrwxrwx  1 root    root         50 Nov 14  2019 bnhelper-tool -> /opt/bitnami/bnhelper/bnhelper-0.1.0-linux-x64.run
drwxr-xr-x  3 root    root       4096 Nov 15 19:14 bnsupport
-rw-r--r--  1 root    root        745 Aug 27  2019 bnsupport-regex.ini
lrwxrwxrwx  1 root    root         52 Nov 15 19:14 bnsupport-tool -> /opt/bitnami/bnsupport/bnsupport-0.9.3-linux-x64.run
-rw-r--r--  1 root    root      30053 Nov 14  2019 changelog.txt
drwxr-xr-x 10 root    root       4096 Nov 14  2019 common
drwxr-xr-x  5 root    root       4096 Nov 14  2019 config
-rwxr-xr-x  1 root    root      46310 Nov 14  2019 ctlscript.sh
drwxr-xr-x  2 root    root       4096 Nov 14  2019 img
drwxr-xr-x  5 root    root       4096 Dec  9  2019 letsencrypt
drwxr-xr-x  3 root    root       4096 Nov 14  2019 licenses
-rwx------  1 root    root    3390885 Aug 27  2019 manager-linux-x64.run
drwxr-xr-x 13 root    root       4096 Dec  9  2019 mysql
drwxr-xr-x 12 root    root       4096 Nov 14  2019 php
-rwxrwx---  1 bitnami root       1926 Nov  9 00:58 properties.ini
-rw-r--r--  1 root    root      12668 Nov 14  2019 README.txt
drwxr-xr-x  3 root    root       4096 Nov 14  2019 scripts
drwxr-xr-x  5 root    root       4096 Nov 14  2019 sqlite
drwxr-xr-x  2 bitnami bitnami    4096 Nov 19 11:26 stats
-rwxr--r--  1 root    root        308 Nov 14  2019 use_wordpress
drwxr-xr-x  7 root    root       4096 Dec  9  2019 var
drwxr-xr-x  9 root    root       4096 Nov 14  2019 varnish`Preformatted text`

and you wanted me to run all of those commands?

sudo cat /opt/bitnami/apache2/conf/bitnami/bitnami.conf:

  # Error Documents
  ErrorDocument 503 /503.html
        
  # Bitnami applications installed with a prefix URL (default)
  Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
</VirtualHost>

# Bitnami applications that uses virtual host configuration
Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf"

# Status
ExtendedStatus on
<VirtualHost _default_:80>
ServerName www.veggovendy.com 
ServerAlias veggovendy.com 
Redirect permanent / https://www.veggovendy.com/
ServerName local-stackdriver-agent.stackdriver.com
<Location /server-status>
  SetHandler server-status
  Order deny,allow
  Deny from all
  Allow from 127.0.0.1
</Location>
</VirtualHost>

sudo cat /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf:

# Bitnami applications installed in a prefix URL
Include "/opt/bitnami/apps/wordpress/conf/httpd-prefix.conf"
                    Include "/opt/bitnami/apps/phpmyadmin/conf/httpd-prefix.conf"

sudo cat /opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf:
# Bitnami applications installed in a Virtual Host

sudo cat /opt/bitnami/apps/wordpress/conf/httpd-prefix.conf:

# App url moved to root
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
    #Alias /wordpress/ "/opt/bitnami/apps/wordpress/htdocs/"
#Alias /wordpress "/opt/bitnami/apps/wordpress/htdocs"

Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"


SetEnvIf x-forwarded-proto https HTTPS=on

sudo cat /opt/bitnami/apps/wordpress/conf/httpd-vhosts.conf:

<VirtualHost *:80>
    ServerName wordpress.example.com
    ServerAlias www.wordpress.example.com
    DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
    
    Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
</VirtualHost>

<VirtualHost *:443>
    ServerName wordpress.example.com
    ServerAlias www.wordpress.example.com
    DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
    SSLEngine on
    SSLCertificateFile "/opt/bitnami/apps/wordpress/conf/certs/server.crt"
    SSLCertificateKeyFile "/opt/bitnami/apps/wordpress/conf/certs/server.key"
    
    Include "/opt/bitnami/apps/wordpress/conf/httpd-app.conf"
</VirtualHost>

sudo cat /opt/bitnami/apps/wordpress/conf/httpd-app.conf:

RewriteEngine On
RewriteRule /<none> / [L,R]

<IfDefine USE_PHP_FPM>
    <Proxy "unix:/opt/bitnami/php/var/run/wordpress.sock|fcgi://wordpress-fpm" timeout=300>
    </Proxy>
</IfDefine>

<Directory "/opt/bitnami/apps/wordpress/htdocs">
    Options +MultiViews +FollowSymLinks
    AllowOverride None
    <IfVersion < 2.3 >
        Order allow,deny
        Allow from all
    </IfVersion>
    <IfVersion >= 2.3>
        Require all granted
    </IfVersion>
    
    
    <IfModule php7_module>
            php_value memory_limit 512M
    </IfModule>

    <IfDefine USE_PHP_FPM>
       <FilesMatch \.php$>
         SetHandler "proxy:fcgi://wordpress-fpm"
       </FilesMatch>
    </IfDefine>

    
    RewriteEngine On
    #RewriteBase /wordpress/
    RewriteRule ^index\.php$ - [S=1]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]

    Include "/opt/bitnami/apps/wordpress/conf/banner.conf"
</Directory>

Include "/opt/bitnami/apps/wordpress/conf/htaccess.conf"

sudo cat /opt/bitnami/apps/wordpress/htdocs/wp-config.php | grep “WP_HOME|WP_SITEURL”:

define('WP_HOME','http://veggovendy.com');
define('WP_SITEURL','http://veggovendy.com');
 * The WP_SITEURL and WP_HOME options are configured to access from any hostname or IP address.
 *  define('WP_HOME','http://example.com');
 *  define('WP_SITEURL','http://example.com');
define('WP_HOME','https://www.veggovendy.com');
define('WP_SITEURL','https://www.veggovendy.com');

Idk if this is what u wanted me to do…

The installation directory looks fine, did you run the Bitnami support tool using sudo?

sudo /opt/bitnami/bnsupport-tool

You didn’t copy the entire content of the file here, can you run the command again and ensure you copy all the lines of the file?

It seems you have multiple WP_HOME and WP_SITEURL lines in the wp-config.php file. I suggest you remove the duplicated ones to avoid issues.

I ran it with sudo and it worked! Here’s my support ticket code: 60440528-dbf1-d2b6-6ab3-65e60d776ebf

If i run sudo cat /opt/bitnami/apache2/conf/bitnami/bitnami.conf i get

sudo cat /opt/bitnami/apache2/conf/bitnami/bitnami.conf
# Default Virtual Host configuration.
<IfVersion < 2.3 >
  NameVirtualHost *:80
  NameVirtualHost *:443
</IfVersion>
<VirtualHost _default_:80>
  DocumentRoot "/opt/bitnami/apache2/htdocs"
  RewriteEngine On 
  RewriteCond %{HTTPS} !=on 
  RewriteRule ^/(.*) https://www.veggovendy.com/$1 [R,L]
  <Directory "/opt/bitnami/apache2/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride All
    <IfVersion < 2.3 >
      Order allow,deny                          
      Allow from all
    </IfVersion>
    <IfVersion >= 2.3 >
      Require all granted
    </IfVersion>
  </Directory>
  # Error Documents
  ErrorDocument 503 /503.html
  # Bitnami applications installed with a prefix URL (default)
  Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
</VirtualHost>
# Default SSL Virtual Host configuration.

I also deleted the duplicated ones in the config file

Hi @veggovendy,

I just saw this in your configuration

<VirtualHost _default_:443>
  DocumentRoot "/opt/bitnami/apache2/htdocs"
ServerName www.veggovendy.com.
ServerAlias veggovendy.com.
Redirect permanent / https://www.veggovendy.com/.

You are creating the redirection loop as you are redirecting to https://www.veggovendy.com/ no matter if the user is already using that domain. If you want to force https and www all time, please substitute the rewrite lines you have with the ones in this Bitnami guide

https://docs.bitnami.com/google/apps/wordpress/administration/use-single-domain/

Happy to help!


Was my answer helpful? Click on :heart:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.