How do I keep only 1 page to http when I have forced a sitewide https?

November 20, 2015 464 views
Apache DNS

On my website, I have one page that loads content in iframe form other sources and hence cannot have an http connection. I have an SSL installed and have a site wide https forced on all urls. I am running Symfony 1.4 application and the rewrites and redirects are various level are:

VirtualHost Setting:

<VirtualHost *:80>
   ServerName myserver.com
   ServerAlias www.myserver.com
   Redirect permanent / https://myserver.com/
</VirtualHost>
<VirtualHost *:443>
  ServerName myserver.com
  ServerAlias www.myserver.com

  SSLEngine on
  SSLCertificateFile /path/to/ssl/myserver.crt
  SSLCertificateKeyFile /path/to/ssl/myserver.key
  SSLCertificateChainFile /path/to/ssl/cert.ca-bundle
  DocumentRoot /var/www/myserver/web
  DirectoryIndex index.php
  <Directory /var/www/myserver>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    Require all granted
  </Directory>
  <Directory "/var/www/hubhopper_1.0/web/images">
    LimitRequestBody 2147483647
  </Directory>

</VirtualHost>

.htaccess:

Options +FollowSymLinks +ExecCGI

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] 
  RewriteRule ^(.*)$ http://%1/$1 [R=301,L]  
  RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{HTTPHOST}%{REQUESTURI} 

  RewriteRule ^$ index.html [QSA]
  RewriteRule ^([^.]+)$ $1.html [QSA]
  RewriteCond %{REQUEST_FILENAME} !-f

  RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

I want that only this page <url>/link-view/<id>, should be on http. I tried modifying the .htaccess by adding these lines:

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} 
RewriteCond %{HTTP_HOST} ^(www\.)?(.*)$ [NC]
RewriteRule ^(.*)$ https://%2/$1 [R=301,L,QSA]

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} lin-view
RewriteCond %{HTTP_HOST} ^(www\.)?(.*)$ [NC]
RewriteRule ^(.*)$ http://www.%2/$1 [R=301,L,QSA]

But it does not work and shows 'too many redirects' on the page. How do I achieve that?

Be the first one to answer this question.