Www needs to be redirected to non www

Hi, all.

Well, I’m back needing more help. Thanks for all your help in the past.

My domain is: SyIHTQ.org

It used to be that when someone types in www.syihtq.org in their browser, it used to automatically go to syihtq.org. I believe this was done by GoDaddy automatically because there were no redirects or anything in my htaccess file.
Now, when someone types in www.syihtq.org now, they get a warning that the website is not safe.

I don’t know if this is new behavior, or if I just never checked it before.

My hosting provider, godaddy, will not allow me to use certbot for my ssl, so I use a cron job to renew using acme.
I recently got this error message:

[Fri Jun 12 00:07:27 MST 2020] newchurchofhope.com:Verify error:Fetching http://newchurchofhope.com/.well-known/acme-challenge/uwgXjb62r8MsoGc2KuOjDTEchPjGyRiocuSfd4iwqC4: Timeout during connect (likely firewall problem)
[Fri Jun 12 00:07:27 MST 2020] Please add ‘–debug’ or ‘–log’ to check more details.
[Fri Jun 12 00:07:27 MST 2020] See: https://github.com/Neilpang/acme.sh/wiki/How-to-debug-acme.sh
[Fri Jun 12 00:07:30 MST 2020] Error renew newchurchofhope.org.
[Fri Jun 12 00:08:15 MST 2020] syihtq.org:Verify error:Fetching http://syihtq.org/.well-known/acme-challenge/OiSFUjWzo5mhYZ9zqpNLlwWLUIMsjNjZcgevB_Aa0i4: Timeout during connect (likely firewall problem)
[Fri Jun 12 00:08:15 MST 2020] Please add ‘–debug’ or ‘–log’ to check more details.
[Fri Jun 12 00:08:15 MST 2020] See: https://github.com/Neilpang/acme.sh/wiki/How-to-debug-acme.sh
[Fri Jun 12 00:08:16 MST 2020] Error renew syihtq.org.

I can login to a root shell on my machine, but I don’t have sudo rights:
I’m using a control panel to manage my site.

Can someone help me with the following:

  1. Is the cron job error message a problem, and if so, what must I do to fix it? Someone here helped me set up the cron job - I’m not a techie and don’t really understand the commands we issued.
  2. Is there something I can add to my htaccess file that will redirect the unsafe www.syihtq.org to the safe syihtq.org?

Thanks
CJ Rhoads

1 Like

There are four possible “sites” for any domain:

  1. http://syihtq.org/
  2. http://www.syihtq.org/
  3. https://syihtq.org/
  4. https://www.syihtq.org/

The first is being redirected to HTTPS (1 > 3).
The second is also being redirected to HTTPS (2 > 4).
The third and fourth have no redirection and are being explicitly redirected to, so they both must work via HTTPS.
[in this current configuration - managed via your control panel]

The current certificate only includes the short name, so that one works as expected.
But the longer (“www”) name is unmatched by the web server and a default site is being served; which of course doesn’t match the name being securely requested and your browser will not like it.

There are two ways to fix this:

  1. add both names to the cert.
  2. ensure that all redirections use only the short HTTPS site name.
1 Like

Thank you so much for your response. Since I don’t feel confident enough in my ability to independently add the www for all my domains to the cron job, I would choose the second one. But again, I’m not sure how to do this. Here is the redirect command that someone here helped me with before. It is shown below for just the syihtq.org, but I have many different domains using the same commands, so the actual htaccess is 33 lines long with four lines for each domain.

RewriteCond %{HTTP_HOST} syihtq.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

So the question is, what do I add in order to get www.syihtq.org to forward to syihtq.org?
I tried adding a line:
RewriteCond %{HTTP_HOST} www.syihtq.org [NC]

But it didn’t appear to work, so either I put it in the wrong place, or that is not the correct syntax.

Also - you mentioned that the redirect of 2-4 is done through the control panel, but I didn’t do it so it must be set up as a default and I don’t know where to go to change it. If there is no way to add a command to the htaccess in order to do the redirect of www.syihtq.org, the perhaps someone could direct me to the proper area of the control panel to make this change.

Can anyone help?
Thanks
CJ Rhoads

1 Like

33 / 4 = 8.25
Not really sure how that works out in actuality.

You said four lines for each, then only show three lines.
Is there a missing line or line that doesn’t show in your post (like a blank line) or a line that has no effect (like comments)?

Anywho, there may be a very simple way to “group” all the redirects into just one, or two, section(s).
But I would have to see them all to be sure [or at least the “template” / “pattern” they all follow].

1 Like

Sorry - I didn’t mean to be confusing. I meant to say three lines for each (not counting the RewriteEngine On line which is in the file twice, but I’m not knowledgeable enough to know whether I can delete the second one). Here is the entire htaccess file.

AddHandler server-parsed .html
RewriteEngine On
RewriteCond %{HTTP_HOST} syihtq.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} syihtq.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} hpl501c3.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} taijiquanenthusiasts.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} asklepiosresearch.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} opfl.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} pagodawriters.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} newchurchofhope.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} taichipark-masterjoutsunghwa.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
RewriteCond %{HTTP_HOST} hplconsortium.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

1 Like

All that amounts to this:

RewriteEngine On

RewriteCond %{HTTP_HOST} asklepiosresearch.org [NC] [OR]
RewriteCond %{HTTP_HOST} hpl501c3.org [NC] [OR]
RewriteCond %{HTTP_HOST} hplconsortium.com [NC] [OR]
RewriteCond %{HTTP_HOST} newchurchofhope.org [NC] [OR]
RewriteCond %{HTTP_HOST} opfl.org [NC] [OR]
RewriteCond %{HTTP_HOST} pagodawriters.com [NC] [OR]
RewriteCond %{HTTP_HOST} syihtq.org [NC] [OR]
RewriteCond %{HTTP_HOST} taichipark-masterjoutsunghwa.org [NC] [OR]
RewriteCond %{HTTP_HOST} taijiquanenthusiasts.org [NC]

RewriteCond %{SERVER_PORT} 80

RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
1 Like

But none of that deals with the “www” versions of those domains.
So that must be happening elsewhere.

1 Like

Well, I know that it doesn’t deal with the www versions of the domains. The question is - COULD it? Is there a command that I can add that would redirect anyone going to www.syihtq.org to https:/syihtq.org?

1 Like

The real question is where is it already doing that?
[recall that 2 is already redirecting to 4]

1 Like

To answer this question:

Yes, but anything we add would conflict with, or may be overridden by, what is already in place.
If you could find and remove the existing inadequate redirection, you could use something like this:

RewriteCond %{HTTP_HOST} www.asklepiosresearch.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://asklepiosresearch.org%{REQUEST_URI} [R,L]
...
{repeat 3 lines for each domain}
...
RewriteCond %{HTTP_HOST} www.taijiquanenthusiasts.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://taijiquanenthusiasts.org%{REQUEST_URI} [R,L]

EDIT: removed the [OR]

2 Likes

Thank you so much for your help. However, I’m a bit confused. It appears that you are suggesting changing the current line:

RewriteCond %{HTTP_HOST} asklepiosresearch.org [NC]

to be

RewriteCond %{HTTP_HOST} www.asklepiosresearch.org [NC]

But perhaps I misunderstood. Doesn’t whatever I do have to be in addition to the current code? Not everyone uses the www, and I want to be sure that people using http://asklepiosresearch.org get redirected to https://asklepiosresearch.org. I’d like to be sure before I change the current code. Any help or explanation would be greatly appreciated.

Also - would there be any advantage to my replacing the whole file with the code that you say “all that amounts to this”? If that would be better, I’ll replace it. I’m just not sure that I understand what OR is. (Of course, I don’t understand what NC is either, but it would be nice not to have so many duplicate lines.)

1 Like

I don’t know that I can explain it any better than to just show you the code I would use:

RewriteEngine On

RewriteCond %{HTTP_HOST} www.asklepiosresearch.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://asklepiosresearch.org%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} www.hpl501c3.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://hpl501c3.org%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} www.hplconsortium.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://hplconsortium.com%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} www.newchurchofhope.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://newchurchofhope.org%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} www.opfl.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://opfl.org%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} www.pagodawriters.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://pagodawriters.com%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} www.syihtq.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://syihtq.org%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} www.taichipark-masterjoutsunghwa.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://taichipark-masterjoutsunghwa.org%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} www.taijiquanenthusiasts.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://taijiquanenthusiasts.org%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} asklepiosresearch.org [NC] [OR]
RewriteCond %{HTTP_HOST} hpl501c3.org [NC] [OR]
RewriteCond %{HTTP_HOST} hplconsortium.com [NC] [OR]
RewriteCond %{HTTP_HOST} newchurchofhope.org [NC] [OR]
RewriteCond %{HTTP_HOST} opfl.org [NC] [OR]
RewriteCond %{HTTP_HOST} pagodawriters.com [NC] [OR]
RewriteCond %{HTTP_HOST} syihtq.org [NC] [OR]
RewriteCond %{HTTP_HOST} taichipark-masterjoutsunghwa.org [NC] [OR]
RewriteCond %{HTTP_HOST} taijiquanenthusiasts.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
2 Likes

Thanks. I’ll try it and let you know if it works.

Peace

CJ

2 Likes

For your edification:
image

2 Likes

Great!!! That’s very helpful.

BTW – I tried it, and it works. Thank you so very much!

CJ

2 Likes

Addendum - Well, I THOUGHT it worked, but alas it broke something else.
After I put in the new code in my .htaccess file none of my menus on any of my websites would appear. I have no idea what the relationship is, but whatever it is the new code completely broke all the websites.
I had to put the old code back in. And people will just have to learn that they cannot go to https://www.domain for any of my websites.

Unless someone else can explain the menu-htaccess connection and why that would happen so that we can figure out what code will enable a redirect to www without causing my menus to disappear, I think I’m going to have to let this one go.

Thanks for trying.

1 Like

If you are willing to try it once more in a slightly different way, here goes:

RewriteEngine On

RewriteCond %{HTTP_HOST} asklepiosresearch.org [NC] [OR]
RewriteCond %{HTTP_HOST} www.asklepiosresearch.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://asklepiosresearch.org%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} hpl501c3.org [NC] [OR]
RewriteCond %{HTTP_HOST} www.hpl501c3.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://hpl501c3.org%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} hplconsortium.com [NC] [OR]
RewriteCond %{HTTP_HOST} www.hplconsortium.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://hplconsortium.com%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} newchurchofhope.org [NC] [OR]
RewriteCond %{HTTP_HOST} www.newchurchofhope.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://newchurchofhope.org%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} opfl.org [NC] [OR]
RewriteCond %{HTTP_HOST} www.opfl.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://opfl.org%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} pagodawriters.com [NC] [OR]
RewriteCond %{HTTP_HOST} www.pagodawriters.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://pagodawriters.com%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} syihtq.org [NC] [OR]
RewriteCond %{HTTP_HOST} www.syihtq.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://syihtq.org%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} taichipark-masterjoutsunghwa.org [NC] [OR]
RewriteCond %{HTTP_HOST} www.taichipark-masterjoutsunghwa.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://taichipark-masterjoutsunghwa.org%{REQUEST_URI} [R,L]

RewriteCond %{HTTP_HOST} taijiquanenthusiasts.org [NC] [OR]
RewriteCond %{HTTP_HOST} www.taijiquanenthusiasts.org [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule .* https://taijiquanenthusiasts.org%{REQUEST_URI} [R,L]

And did ALL the sites have that problem or only specific one(s)?

1 Like

I found that a lot of the links have hardcoded HTTP in them.
This is code found on one of the HTTPS sites:

	<div class="menu-left">
		<h3>About New Church of Hope</h3>

			<li><a href="http://hplconsortium.com/web/newchurchofhope/mission.html"><span class="no">Our Mission</span></a></li>
			<li><a href="http://hplconsortium.com/web/newchurchofhope/history.html"><span class="no">Our History</span></a></li>
			<li><a href="http://hplconsortium.com/web/newchurchofhope/leaders.html"><span class="no">Our Leadership</span></a></li>
			<li><a href="http://hplconsortium.com/web/newchurchofhope/contact.html"><span class="no">Contact Us</span></a></li>


			<h3>Current</h3>
			<li><a href="http://hplconsortium.com/web/newchurchofhope/upcoming.html"><span class="no">Upcoming Event</span></a></li>
			<li><a href="http://hplconsortium.com/web/newchurchofhope/pastevents.html"> Past Events </a></li>
			<li><a href="http://hplconsortium.com/web/newchurchofhope/membersonly.html">Members Only</a> </li>
	</div>


</div>

<div>
<!-- code for bottom menu -->
		<footer>
		<p align="center">	<a href="http://hplconsortium.com/web/newchurchofhope/index.html">Home</a>&nbsp;&nbsp;
			<a href="http://hplconsortium.com/web/newchurchofhope/upcoming.html">Upcoming</a>&nbsp;&nbsp;
			<a href="http://hplconsortium.com/web/newchurchofhope/pastevents.html">Past</a>&nbsp;&nbsp;
			<a href="http://hplconsortium.com/web/newchurchofhope/membersonly.html">Members Only</a>&nbsp;&nbsp;
			<a href="http://hplconsortium.com/web/newchurchofhope/mission.html">Mission</a>&nbsp;&nbsp;
			<a href="http://hplconsortium.com/web/newchurchofhope/history.html">History</a>&nbsp;&nbsp;
			<a href="http://hplconsortium.com/web/newchurchofhope/leaders.html">Leadership</a>&nbsp;&nbsp;
			<a href="http://hplconsortium.com/web/newchurchofhope/contact.html">Contact</a></p>&nbsp;&nbsp;

		<p align="left"> &nbsp;&nbsp;  &nbsp;&nbsp;  &nbsp;&nbsp;  &copy; Copyright, 2014 New Church Of Hope. </p>


		</footer>

</div>
1 Like

I only checked 4 of them, but all 4 had the same problem – no menus.

These sites are written in pure html, by me (amateur hour), and use divs to make the three columns. The left and right columns are fixed width, the middle column changes based upon the width of the portview screen. Mostly they were written in 2014, so it was before I knew about bootstrap or any other responsive framework. I have no idea why a redirect would make the fixed width columns disappear, but apparently it does.

I’ll try the new code.

Thanks

CJ

2 Likes

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