WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to force SSL for all requests? Much like the option to use admin ssl, but for all requests, including the ones who are not logged in.

share|improve this question
up vote 1 down vote accepted

Here is a complete guide - Enable Complete support for SSL on Wordpress

share|improve this answer
    
Page not found. – kosinix Jun 24 at 1:31

A simple check for is_ssl() should do it:

add_action( 'plugins_loaded', 'wpse_2718_force_ssl' );

function wpse_2718_force_ssl()
{
    if ( is_ssl() )
        return;

    wp_redirect(
        'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] 
    );
    exit;
}

But I would do this in .htaccess to catch images too:

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

For ISS see this answer on Stack Overflow.

share|improve this answer

Add this rule to the top of .htaccess:

# BEGIN Force SSL
# This should be the first rule before other rules
<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{HTTPS} !=on
    RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
</IfModule>
# END Force SSL

This should be before WordPress' rules.

share|improve this answer

I've used Really Simple SSL to my all of clients sites and it works very fine. If you dont want to modify code, simply install this plugin and config it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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