• I have recently changed a clients site to HTTPS.

    Everything works fine on HTTPS but when I try and add any Rewrite rules to .htaccess, to force any Google links pointing to HTTP to redirect to HTTPS (via 301) then the site goes into a redirect loop. It also goes into a redirect loop if I try and use any redirect plugins to achieve it.

    In the Dashboard everything looks correct except for the Site Address (URL) for the main site: /wp-admin/network/site-info.php?id=1

    There it shows as http but it’s not directly editable from that screen, or anywhere else in the Dashboard.
    Site 1

    From that screen the URLs are correct in the Settings tab, just not on the Info tab.

    I’ve searched the DB for any instances of the site URL as HTTP but can’t find any. Could it be stored as a different type of string?

    I don’t know if that instance has anything to do with redirect loops but I can’t find any other cause. I’ve looked at countless other threads across google for this type of problem but none of them have offered a resolution for my particular case.

    I’ve contacted the hosting company but they’ve now gone quiet on the matter.

Viewing 7 replies - 1 through 7 (of 7 total)
  • > In the Dashboard everything looks correct except for the Site Address (URL) for the main site: /wp-admin/network/site-info.php?id=1

    You cannot change the protocol, it will always display ‘http’

    > Everything works fine on HTTPS but when I try and add any Rewrite rules to .htaccess, to force any Google links pointing to HTTP to redirect to HTTPS (via 301) then the site goes into a redirect loop.

    Can you show me your .htaccess rule?

    Thread Starter cokeyblokey

    (@cokeyblokey)

    Thanks for replying @jkhongusc

    Here’s my .htaccess rules when the site experiences infinite redirect loops:

    # BEGIN WordPress
    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    RewriteBase /
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]
    # END WordPress

    The rewrite from http to https actually happens but site goes into loop.

    Try this instead:

    
    RewriteCond %{HTTPS}  off
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    

    or

    
    RewriteCond %{HTTPS}  !on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    

    edited out test info

    • This reply was modified 7 years, 7 months ago by jkhongusc.
    Thread Starter cokeyblokey

    (@cokeyblokey)

    Both produce the same result. The rewrite happens but site goes into an infinite redirect loop.

    > Both produce the same result. The rewrite happens but site goes into an infinite redirect loop.

    It works for me on my WP. This is a 301 redirect which would be cached by your browser. Clear your cache, use another browser, or hit a fake url, e.g. https://domain.com/fakepage.html (you should be redirected to https and a WP 404 error page)

    Its possible it wont work if you have special configurations upstream, for example either a load balancer, proxy, or CDN.

    Are you using a sub-directory or sub-domain WP Networked Multi-site installation? If the latter, the SSL Certificate has to be for *.your-domain.TLD

    Are you using a sub-directory or a sub-domain implementation for you WP Networked Multi-site? I prefer using sub-domains, but you have to be very careful about redirects.

    • This reply was modified 7 years, 5 months ago by johngoold. Reason: Incorrect information about General settings
    Thread Starter cokeyblokey

    (@cokeyblokey)

    thanks for your reply @johngoold-1

    I’m using a sub-directory install for the multi-site, as I’ve done many, many times before for other sites.

    In the end I gave up on using an .htaccess rewrite approach and used a plugin called
    ‘Force SSL URL Scheme’ instead.

    I’m still at a complete loss as to where or what the issue was, and I’m disappointed that I had to give up on it due to lack of budget, but since using the plugin everything seems to be ok now.

    • This reply was modified 7 years, 5 months ago by cokeyblokey.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Redirect loop when using 301 redirects’ is closed to new replies.