Too Many Redirects

Trying to force https i.e. htttp://wwwdotmysitedotcodotuk should go to htttps://wwwdotmysitedotcodotuk.

I’ve just moved this site from a dev server to the client’s existing hosting package (which I’m stuck with) and the usual settings in my htaccess file in public_html results in an error ‘too many redirects’. On top of this when I comment out the parts of the htaccess file that cause a problem it takes around 10 refreshes to get the site up and running again which suggests there is some sort of caching in play.

Currently only the friendly URLs part is not commented out in my htaccess file…

# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Even the next part breaks the site if uncommented…

###RewriteEngine On
###RewriteBase /

There is a htaccess file above public_html that contains…

AddHandler x-httpd-php81 .php



…is this likely to be interfering with my htaccess file?

This is MODX 3.0.3. Apart from it being Linux hosting / Apache and PHP8.1 there’s not much more I can see about the hosting.

I’ll raise a support ticket but at the moment can anybody tell me where to start looking for clues?

Whenever I run into this problem it’s usually because my DNS and my host are competing. I use Cloudflare for DNS and I have to set the SSL/TLS setting to Full instead of the default Flexible.

You are probably right. This is an external domain pointed to this hosting account and although I can see the dns I daren’t touch it as they have other services running but there do seem to be duplicated records.

This should be above any rewrite rules or conditions.

1 Like

It is Bob - threw it into the post last of all to illustrate that even if I uncommented that it caused a problem. It is at the top of the htaccess file.

One way or another this seems to be solved. I’ve got very limited access in the control panel - couldn’t even raise a support ticket without going through the IT company manages the hosting on behalf of the client.

I was eventually sent a link to ‘Force HTTPS’ - there’s nowhere in the control panel that was accessible. Once it was switched on, my htaccess file works as expected. It’s a little annoying and worrying that I can’t open or edit the htaccess file from within the manager ‘You do not have permission to access this resource’. That suggests ownership issues or security settings that I don’t have access to.

What makes hosting like this more awkward is some sort of inbuilt caching which I seem unable to disable.

I could do with upgrading this site to 3.0.4 but nervous that something will catch me out.

Do you have File Manager in cPanel? What about PhpMyAdmin?

If you have FM, can you edit .htaccess that way?

If not, that’s a pretty severe handicap (not to mention the host’s willingness to rewrite your .htaccess file, which would make me nervous).

Yeah I can edit the htaccess in FM - no problem, except that until I was able to switch on Force HTTPS anything I did in htaccess was breaking the site.

I wonder if that implies an .htaccess file higher up the tree that’s only visible to the ISP.

I think you are probably right Bob