1

The IONOS help here https://www.ionos.co.uk/help/ssl-certificates/tips-for-setup-and-use/automatically-redirect-visitors-to-ssl-secured-site/ tells me to do the following:

Steps for Windows Packages Open a basic text editor, such as Notepad (Windows) or TextEdit (MacOS). Copy and Paste the code below into the text editor.

<%EnableSessionState=False
host = Request.ServerVariables("HTTP_HOST")

if host = "example.com" or host = "www.example.com" then
response.redirect("https://www.example.com/")

else
response.redirect("https://www.example.com/error.htm")

end if
%>mixed

In the text editor, replace all instances of "example.com" with your own domain. Save the file as index.asp. Upload the File via FTPS to the root of your webspace.

But if I do this, I get an ERR_TOO_MANY_REDIRECTS error message when I type in the address of the website. It tells me to cleardown cookies, which I have done, but that makes no difference. Plus other devices - other PCs, laptops and phones have the same problem.

I made sure there is an error.htm page.

The SSL certificate is valid and there is no problem if you type in the address preceded by https:// - BEFORE implementing OR AFTER reversing the IONOS advice.

I just want is to automatically go to the https version - even if you do not prefix the address with https://.

I have tried editing the web.config but it seems I cannot get this right. - have tried this code for example. Amended to my web address of course.

<rewrite>
      <rules>
         <rule name="Force HTTPS" stopProcessing="true">
           <match url="(.*)" ignoreCase="false" />
            <conditions>
             <add input="{HTTPS}" pattern="off" />
            </conditions>
              <action type="Redirect" url="https://www.example.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>

And get this error:: HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the related configuration data for the page is invalid.

Also tried this - no luck:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <clear />
                <rule name="Redirect to https" stopProcessing="true">
                    <match url=".*" />
                    <conditions>
                        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

My homepage is index.htm so I thought it was strange that the Ionos code recommends creating a .asp page to? But what do I know ---- not much apparently.

Ionos will not help - they say it is outside of their scope.

ITA
  • 351
  • 1
  • 8
  • Also tried this – ITA Jun 30 '21 at 16:35
  • Amazingly, the solution to this question provided the missing part of the puzzle that I was trying to solve on-and-off for more than a year. [I figured out how to stop too many redirects](https://stackoverflow.com/q/60286204/335858) at the expense of not forcing users to https; now I know how to force them back. Thank you very much! – Sergey Kalinichenko Jul 29 '21 at 18:56

1 Answers1

2

I did put effort into researching this (ref the amount of detail above) - so I am disappointed that it got marked down.

But it seems someone in Ionos took pity on me. And put this .htaccess file below in the root of the site.

I did look at this but I could not find the .htaccess file.

THANKYOU!

Contents of .htaccess file

RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]

I edited this to remove a "/" here _HOST}/$1 - line 3 This was adding an extra /to the end of the web address in MS Edge. See Why do I have double slashes at the end of my website URL like this: //

RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R,L]
ITA
  • 351
  • 1
  • 8