I have a problem where I need to redirect 4 specific pages on my website to their https secure versions.
I currently have an htaccess file which is redirecting both
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
#redirect www.mydomain.com to mydomain.com (or any other subdomain)
RewriteCond %{HTTP_HOST} !^mydomain.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com/$1 [L,R=301]
#force https for certain pages
RewriteCond %{HTTPS} !=on
RewriteRule ^(page1\.php|page2\.php|page3\.php|page4\.php)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R]
I have modified and cleaned up your code. You can use this code in your .htaccess file in $DOCUMENT_ROOT:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# HTTPS is not already on
RewriteCond %{HTTPS} !=on
# Redirect to HTTPS is URI is page1.php OR page2.php OR page3.php OR page4.php
RewriteRule ^page[1234]\.php$ https://mydomain.com%{REQUEST_URI} [L,R]