I am trying to solve my https redirection from all away.I follow the all solutions form stackexchange. But still in problem so I am writing here. Problem is that https redirection is working but some url not redirect. For example . http://example.com/contact not redirect on http://example.com/contact. This is my code .

define( 'WP_CACHE', false );

define('FORCE_SSL_ADMIN', true);
define('FORCE_SSL_LOGIN', true);

Thanks for support .

2 Answers 2


Your code redirects the WordPress admin pages to use https (which will work fine), and then sets the site and WordPress addresses (which may auto redirect some pages). Note that FORCE_SSL_LOGIN was deprecated in WordPress version 4.0 (https://codex.wordpress.org/Administration_Over_SSL)

You can force the whole site to use SSL using .htaccess (note to cover WordPress installs to their own directory, it should be the .htaccess in the same server directory that the Site home would use).

Usually that would be:

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

but some hosts require an environment variable:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{ENV:HTTPS} !=on
    RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC]

If you're using Windows hosting .htaccess won't work, you'll need to use web.config

<rule name="HTTPS" patternSyntax="Wildcard" stopProcessing="true">
    <match url="*" />
        <add input="{HTTPS}" pattern="off" />
    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Found" />

Related Considerations

I'd recommend you change all links under your control to use https. Within WordPress the https://en-gb.wordpress.org/plugins/velvet-blues-update-urls/ is very handy for this.

You should consider changing the WordPress URL and the Site URL in the admin instead, and take a look at this good overall guide to migrating WordPress to use https https://reviewofweb.com/how-to/migrate-wordpress-from-http-to-https/

  • 1
    Good answer. Another option for a global search and replace is WP CLI. Commented Jun 22, 2018 at 15:52
  • @query-builder I think you were trying to talk to me but posted under the other answer. Your htaccess below just needs to have https:// in front of your domain to get rid of your endless redirect problem. The site you mentioned loads the http contact page with one 301 redirect to https so you've probably already done that. If my answer helped, please accept it.
    – itinerant
    Commented Jun 23, 2018 at 21:34

You can use Really simple SSL plugin. Or Htaccess code can fix this.

RewriteCond %{HTTP_HOST} ^www.example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301,NC]
  • I just included htacess code Commented Jun 22, 2018 at 8:12
  • intinerant@ here is my .htaccess ..........# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{ENV:HTTPS} !=on RewriteRule ^(.*)$ origin.com.sg/$1 [L,R=301,NC] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress Commented Jun 22, 2018 at 11:11
  • intinerant@After this getting to many redirection. I have changed site url and home url from admin. http to https Commented Jun 22, 2018 at 11:13
  • Please don't recommend plugins in/as an answer. Because the possibility is always around that the plugin is/will be deleted for whatever reason and in such case would your answer be useless.
    – Charles
    Commented Jun 22, 2018 at 18:11

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.