apache - Force https to http redirect except for Wordpress /wp-admin directory -
our https
site indexed on google. need redirected http
. we're using following code:
<ifmodule mod_rewrite.c> options +followsymlinks rewriteengine on rewritebase / rewritecond %{server_port} ^443$ [or] rewritecond %{https} =on rewriterule ^(.*)$ http://www.example.com/$1 [r=301,l] </ifmodule>
to redirect https
http
, , works fine.
however, want exclude of wordpress admin https
http
redirect, i'd keep wordpress admin working on https
, added:
rewritecond %{request_uri} !^wp-admin
taking .htaccess code to:
<ifmodule mod_rewrite.c> options +followsymlinks rewriteengine on rewritebase / rewritecond %{server_port} ^443$ [or] rewritecond %{https} =on rewritecond %{request_uri} !^wp-admin rewriterule ^(.*)$ http://www.example.com/$1 [r=301,l] </ifmodule>
unfortunately not work, , trying load /wp-admin
on https
results in many redirects , wordpress dashboard not load.
www.example.com redirected many times.
would appreciate in excluding /wp-admin https
http
redirect.
try following, should force http except directory wp-admin:
rewriteengine on rewritecond %{http:x-forwarded-ssl} !on rewritecond %{request_uri} ^\/(wp-admin) rewriterule (.*) https://%{http_host}/$1 [l,r=301] rewritecond %{http:x-forwarded-ssl} =on rewritecond %{request_uri} !^\/(wp-admin) rewriterule (.*) http://%{http_host}/$1 [l,r=301]
if have problems above, can try also:
rewriteengine on rewritebase / rewritecond %{https} off rewritecond %{request_uri} ^/wp-admin rewriterule ^(.*)$ https://%{http_host}/$1 [r=301,l] rewritecond %{https} on rewritecond %{request_uri} !^/wp-admin rewriterule ^(.*)$ http://%{http_host}/$1 [r=301,l]
Comments
Post a Comment