php - WordPress SSL redirects through Cloudflare -


i have added website cloudflare use of flexible ssl. on static content ok. example, can access files directly https (ex: https://www.samanik.com/logo.png). can't access wordpress site. have changed both site_url , home_url in db. have added codes .htaccess, when type website without https redirects https (as want). but, nothing shown there. error called err_too_many_redirects don't know how fix problem.

here .htaccess content.

# 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  <ifmodule mod_rewrite.c>  rewritecond %{https} off  rewriterule ^(.*)$ https://%{http_host}%{request_uri} [l,r=301]  rewritecond %{http_host} !^www\.  rewriterule ^(.*)$ https://www.%{http_host}%{request_uri} [l,r=301] </ifmodule> 

can me?

you can redirect https using action hook well.

add below code in **functions.php**:

function redirecttohttps(){  if($_server['https']!="on"){    $redirect= "https://".$_server['http_host'].$_server['request_uri'];     header("location:$redirect");    }} add_action('init','redirecttohttps' ); 

for detailed guide, check here.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -