I currently have a SSL certificate applied to my site and ALL URLs redirect to https correctly. I need one of the URLS to be HTTP. I have the following code in my .htaccess that redirects all pages to HTTPS.
I would like the following URL below to be HTTP and NOT HTTPS.
http://www.example.com/blog_rss.php
RewriteEngine on
RewriteBase /
RewriteCond %{ENV:HTTPS} !on [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
Thanks in advance for your assistance
You can replace your current code by this one in your htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/blog_rss\.php$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L,QSA]
RewriteCond %{HTTPS} on
RewriteRule ^(blog_rss\.php)$ http://%{HTTP_HOST}/$1 [R=301,L,QSA]
EDIT: looks like %{HTTPS}
is not recognized on some servers, which is causing an infinite loop.
Try with %{SERVER_PORT}
(if default http port is still 80 and ssl port is 443)
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/blog_rss\.php$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L,QSA]
RewriteCond %{SERVER_PORT} 443
RewriteRule ^(blog_rss\.php)$ http://%{HTTP_HOST}/$1 [R=301,L,QSA]
You could also try with your initial syntax
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:HTTPS} !on [NC]
RewriteCond %{REQUEST_URI} !^/blog_rss\.php$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L,QSA]
RewriteCond %{ENV:HTTPS} on [NC]
RewriteRule ^(blog_rss\.php)$ http://%{HTTP_HOST}/$1 [R=301,L,QSA]
I got similar issue, I have a SSL certificate applied to my sub domain(abc.example.in) and ALL URLs redirect to https correctly.
I need one of the page to be HTTP. I have the following code in my .htaccess that redirects all pages to HTTPS.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^abc\.example\.in$
RewriteCond %{REQUEST_URI} !^/driving\.php$
RewriteRule .* https://abc\.example\.in%{REQUEST_URI} [R=301,L]
It still redirects to https, when i hit URL(abc.example.in/driving.php) in browser, please suggest.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.