I have used htaccess to force all pages to re route to https using...
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://ourdomain.com/$1 [R,L]
Is there any way I can reverse that rule for ourdomain.com/videos && ourdomain.com/blog making sure that these pages are forced to drop the https and use http?
You're already part way there with your use of RewriteCond
to restrict the rewrites to requests on port 80.
You do not want to rewrite requests on port 80 for /videos
and /blog
, so:
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/videos
RewriteCond %{REQUEST_URI} !^/blog
RewriteRule ^(.*)$ https://ourdomain.com/$1 [R,L]
And you want to rewrite requests for these URLs on port (presumably) 443:
RewriteCond %{SERVER_PORT} 443
RewriteRule ^/((videos|blog)/.*) http://ourdomain.com/$1 [R,L]
Try
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} 443
RewriteRule ^blog/?(.*) http://ourdomain.com/blog/$1 [R,L]
RewriteCond %{SERVER_PORT} 443
RewriteRule ^videos/?(.*) http://ourdomain.com/videos/$1 [R,L]
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/videos
RewriteCond %{REQUEST_URI} !^/blog
RewriteRule ^(.*)$ https://ourdomain.com/$1 [R,L]
one more solution. I hope it may help.
RewriteEngine on
Rewritebase /
RewriteCond %{SERVER_PORT} !^443$ [OR]
RewriteCond %{HTTPS} =off [OR]
RewriteCond %{ENV:HTTPS} =off
RewriteRule ^(/(.*))?$ https://%{HTTP_HOST}/$1 [R=301,L]
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.