• Resolved junior013

    (@junior013)


    After installing the plugin everything worked fine. But when going to the setting the plugin recommends to change the redirect from java to htacces. but when adding the following code i cant make a connection to the website.

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    </IfModule>

    Perhaps i am not doing it right? my htaccces. file is the standard wordpress code. This is what my htacces file looks like:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    </IfModule>
    # END WordPress

    This is what my browser says: Deze webpagina bevat een omleidingslus

    I also tried adding the following rule to my wp-config.php file:

    define( ‘RLRSSSL_DO_NOT_EDIT_HTACCESS’ , TRUE );

    But that also doesn’t work..

    https://wordpress.org/plugins/really-simple-ssl/

Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    Hi,

    There seems to have been an error in the rules generated for you. As there is no condition in these rules, the rule redirects all requests (http as well as https) to https. A redirect loop is the result. This omission is caused by the plugin not being able to detect your ssl configuration. I will fix this in the next version.

    Because the plugin could not detect the ssl configuration, this might not be the correct redirection rule, the below one works in most cases, but not in all. Contact me if the rule below doesn’t work, so we can work out which one to use.

    You could try:

    RewriteEngine on
    RewriteCond %{HTTPS} !=on [NC]
    RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    </IfModule>

    But you should not add them within the wordpress comments, otherwise these rules will removed when you save the permalinks again.

    In most cases, when the plugin tests the .htaccess rules, it inserts them automatically. When the test fails the plugin suggests some code to try it yourself.

    Thread Starter junior013

    (@junior013)

    Hi,

    When i add the code from above it is still showing the redirect loop. I placed it in my htacces like this:

    # BEGIN WordPress
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTPS} !=on [NC]
    RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    </IfModule>
    
    # END WordPress

    Am i doing it wrong or is there perhaps something else that is conflicting?

    Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    Hi,

    If that doesn’t work, probably your {https} variable is not set.
    Remember to add the rules outside your wordpress comments!

    you could try replacing
    RewriteCond %{HTTPS} !=on [NC]
    with one of the following options:

    RewriteCond %{HTTPS} !=1
    OR
    RewriteCond %{SERVER_PORT} !443
    OR
    RewriteCond %{HTTP:X-Forwarded-Proto} !https

    The last one only in combination with an addition to the top op your wp-config.php:

    if (isset($_SERVER["HTTP_X_FORWARDED_PROTO"] ) && "https" == $_SERVER["HTTP_X_FORWARDED_PROTO"] )
    {$_SERVER["HTTPS"] = "on";}

    If none of this works, you have a configuration different from the ones I know, I’ll need access to your ftp and wordpress admin to do more.

    Rogier

    Sn00z389

    (@webmakers2011)

    Hi, I was having the exact same problem with the redirect loop with the code

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    </IfModule>

    but when I tried with this code:

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTPS} !=on [NC]
    RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    </IfModule>

    the things started to look better.

    The main page is 301 redirecting to the https version, but other pages on the site like articles and products http version is not redirecting to the https via a 301 redirect but only with JavaScript.

    How can I make all of the pages to redirect via 301 redirect to their https versions, not using JavaScript but with .htaccess???

    Thread Starter junior013

    (@junior013)

    oke, i tried it like this.

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    
    RewriteEngine on
    RewriteCond %{HTTPS} !=on [NC]
    RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    </IfModule>

    I’ve added the rules outside the wordpress comments. like you said. Well at least thats what I think you ment. I’m posting the complete codes because i have no idea what the htacces file should look like and what should go where 😛

    I replaced RewriteCond %{HTTPS} !=on [NC]

    for

    RewriteCond %{HTTPS} !=1

    and after that this one

    RewriteCond %{SERVER_PORT} !443

    Unfortunally both didnt work. So now i’m down at the last option. But I was not quite sure were exactly I have to place the wp-config code you mentioned above. Completely at the top? Or just below the @wordpress package?

    Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    Hard to say, as I don’t know your setup, but you could just try a different rewrite rule:

    RewriteEngine On
    RewriteCond %{HTTPS} !=on [NC]
    RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]

    Let me know if that works for you. Otherwise, we’d have to do some testing on your website.

    Rogier

    Thread Starter junior013

    (@junior013)

    I Tried it like this

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    
    RewriteEngine On
    RewriteCond %{HTTPS} !=on [NC]
    RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]

    so without the opening <IfModule mod_rewrite.c> and closing </IfModule> tags. I’m not sure if these are necessary or not, since my php knowledge is absolutely 0. But this also didn’t work 🙁

    Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    This might get a bit confusing, as you two don’t have exactly the same problem. My previous comment was meant for webmakers2011…

    In response to junior13: adding the ifmodule tags is better, but probably not your issue here. I’d have to access your system to look at your issue, otherwise it’ll just be guesswork

    Thread Starter junior013

    (@junior013)

    Yup bit confusing 😛 I’ve send you an email.

    Sn00z389

    (@webmakers2011)

    Just tried the:

    RewriteEngine On
    RewriteCond %{HTTPS} !=on [NC]
    RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]

    and again it works only for the home page, not the inner pages. All of other pages have the 200OK response when http:// only the home page has the 301 Moved Permanently https://.

    Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    @webmakers2011, I’m not sure, can’t find anything about this online and haven’t encountered it myself.

    This might be a server setting, so maybe you could check with your hosting provider as well?

    You could also try googling on https redirects, and see if you can find some different versions to try. Send me some ftp details if you want me to help you with that.

    Rogier

    Sn00z389

    (@webmakers2011)

    Hi, everything was fixed by adding these lines at the top of the .htaccess:

    RewriteEngine On
    #RewriteCond %{HTTP_HOST} ^SITENAME.com
    RewriteCond %{HTTPS} !=on [NC]
    RewriteRule ^(.*) https://SITENAME.com/$1 [R=301,L]

    Now all the pages redirect correctly to the https version of the site.

    Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    Great, that’s good news!

    I seems to me that the problem was caused by the %{SERVER_NAME} variable. It could be that it was not set correctly. In that case,

    RewriteEngine On
    RewriteCond %{HTTPS} !=on [NC]
    RewriteRule ^(.*) https://SITENAME.com/%{REQUEST_URI} [R=301,L]

    would also work. I’ll work on a check for this specific issue.

    By the way, you should add
    define( 'RLRSSSL_DO_NOT_EDIT_HTACCESS' , TRUE );
    to your wp-config.php to prevent the plugin from editing your .htaccess anymore.

    Rogier

    Thread Starter junior013

    (@junior013)

    Thanks for the help, everything is working fine now 😉 But one more question. I was in the assumption that when the https redirect was active, this would also solve my “www resolve” problem.

    But it seems that i assumed wrong, since www and non www are not refering to the “same” website. I tried adding a code to my htacces but probably it is conflicting with the code that is in there for the https redirect.

    this is what my htacces file looks like now:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    # BEGIN rlrssslReallySimpleSSL rsssl_version[2.1.17]
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    </IfModule>
    # END rlrssslReallySimpleSSL

    This is the code I wanted to add, but as you can probably guess it didnt work like that 😛

    //Rewrite to www
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^mysite.nl[nc]
    RewriteRule ^(.*)$ http://www.mysite.nl/$1 [r=301,nc]

    is there a way to somehow implement this code? I you have any suggestions i’d be happy to hear them.

    Junior

    Plugin Contributor Rogier Lankhorst

    (@rogierlankhorst)

    I assume your code resulted in a redirect loop, as it redirects all incoming requests.

    A rewrite from non www to www in .htaccess:
    #check for the rewrite module

    <IfModule mod_rewrite.c>
    #start rewrite engine
    RewriteEngine on
    #Condition: all requests without www
    RewriteCond %{HTTP_HOST} !^www\.
    #redirect to www
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    </IfModule>

    Best to add it at the top of your .htaccess file. This way, the url first get’s rewritten to www.

Viewing 15 replies - 1 through 15 (of 18 total)

The topic ‘Changing the htacces. file – Redirect loop’ is closed to new replies.