Getting some issues with apache rewrite. The entire of my website works over SSL (online shop), aside from one page (visit_us.php) having a google maps API onto it (since Google charges $$$$$ for HTTPS access). With this particular page exhibiting a note every who's incorporated unsecure content (which sounds bad to the finish-user), i implemented an easy apache rewrite rule to change to port 80 and delay pills work fine.

RewriteEngine On

#redirect all http traffic to https, unless visit_us.php is requested
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/visit_us\.php
RewriteRule ^(.*)$ https://www.myurl.com/$1 [R=301,L]

#redirect https traffic for visit_us.php to http
RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} ^/visit_us\.php
RewriteRule ^(.*)$ http://www.myurl.com/$1 [R=301,L]

However, upon integrating the twitter widget (which could only operate over HTTP), i realized i would need to add the social media page towards the list that works over port 80. I figured this is not so difficult, adding the social.php page towards the list above, as so:

RewriteEngine On

#redirect all http traffic to https, unless visit_us.php or social.php is requested
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/visit_us\.php
RewriteCond %{REQUEST_URI} !^/social\.php
RewriteRule ^(.*)$ https://www.myurl.com/$1 [R=301,L]

#redirect https traffic for visit_us.php and social.php to http
RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} ^/visit_us\.php
RewriteCond %{REQUEST_URI} ^/social\.php
RewriteRule ^(.*)$ http://www.myurl.com/$1 [R=301,L]

During my site, i clearly connect to HTTP, instead of HTTPS. However, even though it still works best for the visit_us.php page, the social.php page appears to become overlooked and demands constantly finish on port 443. What shall we be held doing wrong?

#redirect https traffic for visit_us.php and social.php to http
RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} ^/visit_us\.php
RewriteCond %{REQUEST_URI} ^/social\.php
RewriteRule ^(.*)$ http://www.myurl.com/$1 [R=301,L]

You can't use default AND logic for rewrite conditions here -- it needs to be OR logic rather (read your conditions in plain British and you'll begin to see the flaw).

Two approaches:

1. Clearly specify that OR logic ought to be used:

#redirect https traffic for visit_us.php and social.php to http
RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} ^/visit_us\.php [OR]
RewriteCond %{REQUEST_URI} ^/social\.php
RewriteRule ^(.*)$ http://www.myurl.com/$1 [R=301,L]

2. Merge two rewrite conditions into one (where OR logic can be used):

#redirect https traffic for visit_us.php and social.php to http
RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} ^/(visit_us|social)\.php
RewriteRule ^(.*)$ http://www.myurl.com/$1 [R=301,L]