: How to redirect HTTPS to HTTP behind proxy (CloudFlare) I want to redirect HTTPs to HTTP, I tried following code in .htaccess file Options +FollowSymlinks RewriteEngine on RewriteCond %{SERVER_PORT}
I want to redirect HTTPs to HTTP, I tried following code in .htaccess file
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ www.yourdomain.com/ [R=301,L]
I also tried the following code in .httaccess file, which also did not work.
Options +FollowSymlinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ %{HTTP_HOST}/ [R=301,L]
# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
</IfModule>
I also tried a few HTTPS to HTTP WordPress plugins as well, which also did not work.
Please guide me on how can I resolve this issue.
More posts by @Annie201
1 Comments
Sorted by latest first Latest Oldest Best
yes, I am using Flexible SSL (Free) cloudflare service
This is the "problem". As Antony suggests in comments. Your server is responding to requests on port 80 (plain HTTP). The SSL connection is only between the visitor and CloudFlare. The connection between CloudFlare and your server is not encrypted. This is what the "Flexible SSL" (Free) CloudFlare service is.
Reference: support.cloudflare.com/hc/en-us/articles/200170416-What-do-the-SSL-options-mean-
Since you seem to want to redirect all requests to HTTP, then you should disable the SSL option at CloudFlare.
UPDATE: Since your server is working on plain HTTP and the SSL is being handled by the front end proxy (CloudFlare in this case) then the only way to detect the protocol of the original request (ie. HTTP or HTTPS) is if the proxy sends this information in an HTTP request header, ie. X-Forwarded-Proto by convention.
From Wikipedia - List of HTTP header fields - X-Forwarded-Proto:
a de facto standard for identifying the originating protocol of an HTTP request, since a reverse proxy (or a load balancer) may communicate with a web server using HTTP even if the request to the reverse proxy is HTTPS.
Incorporating this into an HTTPS to HTTP redirect:
RewriteCond %{HTTP:X-Forwarded-Proto} =https [NC]
RewriteRule (.*) www.example.com/ [R=301,L]
Reference:
Cloudflare Support - How do I fix the infinite redirect loop error after enabling Flexible SSL with WordPress? (includes relevant non-WordPress information)
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.