1

After switching to https://, all of our articles have lost their Facebook "Like" count. So I would like to disable https just for the Content area of our website, which is at /content.php (articles are in the form of content.php?212-My-Article)

My current .htaccess:

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

What do I need to add, in order to redirect all content.php* traffic to http (non-secure), even if they type "https"

Thanks!

anubhava
  • 761,203
  • 64
  • 569
  • 643
PF Billing
  • 585
  • 2
  • 6
  • 16
  • 1
    If anyone is aware of a solution that would allow me to use HTTPS and retain the Likes, this would of course be the preferred method! – PF Billing Oct 02 '13 at 13:45

4 Answers4

0

You can use this code:

RewriteEngine on

# uri is not /content.php
RewriteCond %{REQUEST_URI} !^/content\.php$ [NC]
# https is off
RewriteCond %{HTTPS} off
# redirec to https site
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
anubhava
  • 761,203
  • 64
  • 569
  • 643
0

I found a way to fix this, without making content.php be unsecure. The Facebook "Like" HTML code looks like this:

<fb:like href="https://www.mysite.com/{vb:raw relpath}" font="tahoma" layout="standard" show_faces="false" width="260" action="like" colorscheme="light"></fb:like>

I use vBulletin. I changed it to http, and everything is fine now!

PF Billing
  • 585
  • 2
  • 6
  • 16
0

You'll need to make a change to your first rule to exclude content.php. The you simply add a rule for content.php that will do exactly the opposite of your other rule. You can add the [R=301] flag if your rules do what you expect them to do to turn them into permanent redirects. Permanent redirects are cached by the browser and will reduce the amount of requests done to your server. You don't need to use a capturing group for your first rule, and therefore I just used the ^ syntax, which matches every request.

RewriteEngine on

#Turn the entire site into https, except for content.php
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/content\.php$
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}

#Use http instead for this url
RewriteCond %{HTTPS} on
RewriteCond ^content\.php$ http://%{HTTP_HOST}%{REQUEST_URI}
Sumurai8
  • 20,333
  • 11
  • 66
  • 100
0

There is a very easy solution: with the og:url meta tag:

<meta property="og:url" content="http://example.com/old-url" />

You can read more about that into the FAQ section: https://developers.facebook.com/docs/plugins/faqs

The section is called: How do I move a page to a different URL?

Hristo Eftimov
  • 13,845
  • 13
  • 50
  • 77