Forum Moderators: phranque
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} login.php
RewriteRule ^(.*)$ https://www.domain.com/login.php [R,L] RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} somefolder
RewriteRule ^(.*)$ https://www.domain.com/somefolder/$1 [R,L]
# HTTPS 301 redirect on login.php and signup.php
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(login.php|signup.php)$ https://%{HTTP_HOST}/$1 [R=301,L]
# HTTP 301 redirect
RewriteCond %{SERVER_PORT} ^443$
RewriteRule !^(login.php|signup.php)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# HTTPS 301 redirect on login.php and signup.php
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(login.php|signup.php)$ https://%{HTTP_HOST}/$1 [R=301,L]
# HTTP 301 redirect
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{REQUEST_URI} !^/(login.php|signup.php)$
RewriteRule ^$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteEngine On
#
# Externally redirect http requests for login and signup page to https
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^((login|signup)\.php)$ https://%{HTTP_HOST}/$1 [R=301,L]
#
# Externally redirect https requests for everything except login and signup
# pages and the resources shared between http and https to http
RewriteCond %{SERVER_PORT} =443$
RewriteCond $1 !\.(gif|jpe?g|jpg|png|ico|css|js)$
RewriteCond $1 !^((login|signup)\.php)$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]