2

I have the following code to force ssl on the login and admin pages via the .htaccess on a the domain example.com

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/wp-(admin|loginurl) [NC]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} example\.com$ [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R,QSA]
</IfModule> 

I'm also using iThemes Security 'Hide-backend' to change the wp-login to 'loginurl' due to a plugin conflict i can't use iThemes Security ssl features which forces ssl via the wp-config

The problem is with the above code ssl is not applied to the login or wp-admin pages. These pages are still served as http//

How can I modify the .htaccess to force ssl on the login and admin pages?

3
  • RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI}
    – fuxia
    Jun 17, 2015 at 0:32
  • Hi can you please expand on your comment. Are you making a suggestion, asking a questions or providing an answer? Thanks
    – Oudin
    Jun 17, 2015 at 19:11
  • You are sending the visitors to http, not to https.
    – fuxia
    Jun 17, 2015 at 19:16

1 Answer 1

2

You can use the define('FORCE_SSL_LOGIN', true); options provided by WP. You just have to add the line in wp-config.php. Here is the link to wordpress codex, in case that you need more examples.

2
  • Please read my question before answering I stated this can't be done via the wp-config due to a conflict. Thanks
    – Oudin
    Jun 17, 2015 at 19:09
  • sorry about that. you can try like this <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} wp-admin RewriteRule ^(.*)$ https://www.example.com/wp-admin/$1 [R,L] </IfModule> Jun 18, 2015 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.