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 example.com and www.example.com to https://example.com
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*\.)*example.com$ [NC]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://example.com/$1 [R]
what I need is something like
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*\.)*example.com/page1.php$ [NC]
RewriteCond %{HTTP_HOST} ^(.*\.)*example.com/page2.php$ [NC]
RewriteCond %{HTTP_HOST} ^(.*\.)*example.com/page3.php$ [NC]
RewriteCond %{HTTP_HOST} ^(.*\.)*example.com/page4.php$ [NC]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://example.com/page1.php$1 [R]
RewriteRule ^(.*)$ https://example.com/page2.php$1 [R]
RewriteRule ^(.*)$ https://example.com/page3.php$1 [R]
RewriteRule ^(.*)$ https://example.com/page4.php$1 [R]
Notice that I have removed the third RewriteCond line from the above code as I don’t want every page on my website to be displaying https only the pages I specifically state.
How can I resolve this problem?
PS also, is this line covering both http://www.example.com and example.com?
RewriteCond %{HTTP_HOST} ^(.*\.)*example.com$ [NC]
I’m assuming that
^(.*\.)*
has something do with it?
1 Answer