Too many redirects apache2

I installed a certificate, and now when I bring up the site in any browser or cli wget I get the too many redirects. An example of:

All the other answers seem to be for nginx, not apache2.

Thank you!!!!

:/$ wget raqia.org
--2021-12-03 03:24:43--  http://raqia.org/
Resolving raqia.org (raqia.org)... 45.32.222.167
Connecting to raqia.org (raqia.org)|45.32.222.167|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://raqia.org/ [following]
--2021-12-03 03:24:43--  https://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://raqia.org/ [following]
--2021-12-03 03:24:43--  http://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://raqia.org/ [following]
--2021-12-03 03:24:43--  https://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://raqia.org/ [following]
--2021-12-03 03:24:43--  http://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://raqia.org/ [following]
--2021-12-03 03:24:43--  https://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://raqia.org/ [following]
--2021-12-03 03:24:43--  http://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://raqia.org/ [following]
--2021-12-03 03:24:43--  https://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://raqia.org/ [following]
--2021-12-03 03:24:43--  http://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://raqia.org/ [following]
--2021-12-03 03:24:43--  https://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://raqia.org/ [following]
--2021-12-03 03:24:43--  http://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://raqia.org/ [following]
--2021-12-03 03:24:43--  https://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://raqia.org/ [following]
--2021-12-03 03:24:43--  http://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://raqia.org/ [following]
--2021-12-03 03:24:43--  https://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://raqia.org/ [following]
--2021-12-03 03:24:43--  http://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://raqia.org/ [following]
--2021-12-03 03:24:43--  https://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://raqia.org/ [following]
--2021-12-03 03:24:43--  http://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://raqia.org/ [following]
--2021-12-03 03:24:43--  https://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://raqia.org/ [following]
--2021-12-03 03:24:43--  http://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://raqia.org/ [following]
--2021-12-03 03:24:43--  https://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://raqia.org/ [following]
--2021-12-03 03:24:43--  http://raqia.org/
Connecting to raqia.org (raqia.org)|45.32.222.167|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://raqia.org/ [following]
20 redirections exceeded.

Please fill out the fields below so we can help you better. Note: you must provide your domain name to get help. Domain names for issued certificates are all made public in Certificate Transparency logs (e.g. crt.sh | example.com), so withholding your domain name here does not increase secrecy, but only makes it harder for us to provide help.

My domain is: raqia.org

I ran this command: installed cert

It produced this output: it stated cert was issued

My web server is (include version): apache2

The operating system my web server runs on is (include version): ubuntu 21.10

My hosting provider, if applicable, is: vultr

I can login to a root shell on my machine (yes or no, or I don't know): yes

I'm using a control panel to manage my site (no, or provide the name and version of the control panel): no

The version of my client is (e.g. output of certbot --version or certbot-auto --version if you're using Certbot): 1.21.0

2 Likes

Welcome to the community @Wilsont

Your Apache system is redirecting requests wrong.

As shown in your post, requests to http are redirected to https. That's fine and normal. But, requests to https redirect back to http which direct back to https without end. You should review your rewrite and redirect definitions in your VirtualHost and/or .htaccess.

Your wget example shows it but here is a curl example showing the actual http response headers. Note the 301 http response code (permanent redirect) and the Location:

curl -I http://raqia.org
HTTP/1.1 301 Moved Permanently
Date: Fri, 03 Dec 2021 04:08:41 GMT
Server: Apache/2.4.48 (Ubuntu)
Location: https://raqia.org/
Content-Type: text/html; charset=iso-8859-1

curl -I https://raqia.org/
HTTP/1.1 301 Moved Permanently
Date: Fri, 03 Dec 2021 04:08:47 GMT
Server: Apache/2.4.48 (Ubuntu)
Set-Cookie: PHPSESSID=2pi67gqlgav2nk0fn3r0u6on33; path=/; HttpOnly
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Location: http://raqia.org/
Content-Type: text/html; charset=UTF-8

curl -I http://raqia.org/
HTTP/1.1 301 Moved Permanently
Date: Fri, 03 Dec 2021 04:08:54 GMT
Server: Apache/2.4.48 (Ubuntu)
Location: https://raqia.org/
Content-Type: text/html; charset=iso-8859-1

(and repeat 301 redirect pattern forever)

This really has nothing to do with your certificates directly but if you post your Apache conf someone here may point out what is wrong (maybe even me). If you do not know where these are then start with showing results of this command:

sudo apachectl -t -D DUMP_VHOSTS
3 Likes

I see you fixed the problem with your redirects.

You might also want to get a certificate for both raqia.org and www.raqia.org so that this URL would work:

https://www.raqia.org

It is not required to do this but search engines like both to work and some people use that form first too.

You did not show your certbot command but often you just specify both domains like

-d "raqia.org,www.raqia.org"
3 Likes

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