SSL breaks Facebook Likes button - php

My blog https://sonicscoop.com has older posts dating all the way back to 2012 with hundreds of Facebook "likes" such as this one https://sonicscoop.com/2012/08/29/the-big-list-of-free-pro-tools-plugins-2/, but they all lost their correct count when we switched to https: as you can see here:
https://developers.facebook.com/tools/debug/sharing/?q=https%3A%2F%2Fsonicscoop.com%2F2012%2F08%2F29%2Fthe-big-list-of-free-pro-tools-plugins-2%2F
For some reason Facebook's debugger is detecting the canonical and og:url as https:// even though the page's rendered HTML shows them as http://.
If I can get Facebook to pick up the http canonical for older posts I'm hoping the likes will return to the correct count. Here is my .htaccess file:
# --enable htaccess rewrites
RewriteEngine on
# --force https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
# --remove www for site
RewriteCond %{HTTP_HOST} ^www\.sonicscoop\.com [NC]
RewriteRule ^(.*)$ https://sonicscoop.com/$1 [L,R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
AddHandler application/x-httpd-php54s .php

Try below solution
1) WordPress Dashboard
2) After moving your site files (if necessary), log into your your WordPress Dashboard as an administrator.
Next, click on Settings from the menu, and then General.
3) Click on General to get started.
4) The two fields we'll change are WordPress Address (URL) and Site Address (URL) set https for both url
5) Scroll down the page and click on the Save Changes button.
6) After that Settings > Permalinks
7) Scroll down if needed and click "Save Changes".
after above all steps check og:url then check if FB like is working for you.

When facebook crawl your page it got redirected to https version of your page. Even if your og:url use http version, I think facebook will still use the canonical or final url of your page.
Try to change your rewrite condition on .htaccess into something like:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_USER_AGENT} !facebookexternalhit/[0-9]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
# --remove www for site
RewriteCond %{HTTP_HOST} ^www\.sonicscoop\.com [NC]
RewriteRule ^(.*)$ https://sonicscoop.com/$1 [L,R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
AddHandler application/x-httpd-php54s .php

You can use Really simple SSL plugin if it is wordpress site.
Install plugin and activate.
Go to settings you can see SSL. CLICK on it.
enable ssl.
This plugin will take all ssl issues.

Related

Redirect all domains of .com to .org on a wordpress site

I need a help on a site redirection, i have 2 domains : mywebsite.com and mywebsite.org, they both point to the same site (wordpress), and the .com is already indexed by google, i want to redirect all *.com links to www.mysite.org links also all non www of .org to www.mywebsite.org
I have done like this but nothing works :
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS_HOST} ^(www\.)?mywebsite\.com$ [NC]
RewriteRule ^(.*)$ http://www.mywebsite.org/$1 [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
What i have done wrong here?
thank you
RewriteCond %{HTTPS_HOST} ^(www\.)?mywebsite\.com$ [NC]
RewriteRule ^(.*)$ http://www.mywebsite.org/$1 [R=301,L]
As noted in comments, HTTPS_HOST does not exist, it should be HTTP_HOST. So, the above condition will simply fail to match and no redirect occurs.
So, if you correct the above variable then this should work to redirect all traffic from mywebsite.com to www.mywebsite.org, maintaining the URL-path.
However, since this is WordPress, you should avoid manually editing the directives that are part of the front-controller, ie. the code between the # BEGIN WordPress and # END WordPress comment markers. Any redirect that you add should go before the # BEGIN WordPress block at the top of the `.htaccess file.
This also doesn't redirect the non-www version of the .org domain.
If you only have these 2 domains then you can simplify the redirect by checking that the requested hostname is not the canonical hostname (ie. is not www.mywebsite.org) and redirecting accordingly.
Try the following instead:
Options +FollowSymlinks
# Canonical redirect
RewriteCond %{HTTP_HOST} !^www\.mywebsite\.org$
RewriteRule (.*) http://www.mywebsite.org/$1 [R=302,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
<IfModule>
# END WordPress
The ! prefix on the CondPattern negates the regex, so the condition is only successful when it does not match.
Test with 302 (temporary) redirects and only change to 301 (permanent) when you are sure this is working OK - to avoid potential caching issues.
Make sure you have cleared your browser cache before testing.
Note that you are redirecting to HTTP (not HTTPS) - is that intentional?

Wordpress has a nasty redirect not allowing ssl

I am encountering a problem with my wordpress page. I am using the sporty theme and have setup the page. Now I would like to activate SSL.
What have I done:
I changed
siteurl and home in the wp-options table
I used the DB Migrate plugin to modify all links.
I set up my htaccess file like this
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I am still stuck with a redirect to the base url which start with http. Even if I remove the htaccess this happens, so i doubt the htaccess is the problem.
I also tried adding
define('WP_HOME','https://tc-eislingen.de');
define('WP_SITEURL','https://tc-eislingen.de');
to the wp-config.php but the nasty redirect to http stays.
Is there a redirect in the template I am missing?
Update
Why the downvote? I followed all the rules? Is there anything wrong why my quesiton?
you shouldn't be changing .htaccess file code for it. Just change the urls in database and install
Really Simple SSL
and activate necessary settings in it. You must change http: url you placed manually into https though.

SSL only working on half of site

I have an SSL through Cloudflare and it only works on my main site, and not the wordpress part.
regular site:
http://championsdrivingschools.com
wordpress
http://championsdrivingschools.com/checkout/
If I do force SSL on the site it makes the wordpress look all it style and everything and it looks just like text
If you have added static URL in the pages without https then Url will not show green sign in the browser. please check static URL of any static assets and set below setting to make all pages with https.
Step 1: In your WordPress administrator dashboard, go to Settings -> General and change both URLs to have https:// rather than http://.
Step 2: These site asset files can easily be corrected by fixing the rewrite rules in your .htaccess file found at the root of your WordPress application.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
To get started, head to WooCommerce > Settings.

SSL Forcing through .htaccess results in redirect loop on wordpress

I'm trying to force SSL on my Wordpress site. I've followed every step I've found on the internet (force_ssl_admin, set site to https://), but when changing the .htaccess file to what it should be to force ssl I'm stuck on a redirect loop. I found this post where someone has the same issue but it appears unresolved. I'm not sure if my issue is entirely the same so that's why I'd like to make a post about my issue.
When I add this .htaccess:
SetEnvIf X-Forwarded-Proto https HTTPS
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite.be [NC,OR]
RewriteCond %{HTTP_HOST} ^www.mysite.be [NC]
RewriteRule ^(.*)$ https://www.mysite.be/$1 [L,R=301,NC]
</IfModule>
# END WordPress
I'm stuck at a redirect loop. (Of course my site is changed to my domain) Going back to this .htaccess:
SetEnvIf X-Forwarded-Proto https HTTPS
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Allows me to get back on my wp-pages. Maybe a little sidenote: My site itself still works with the redirect loop, only the admin pages are in a redirect loop.
sidenote: I've tried the plugin simple-ssl before, this worked to force the ssl but it also made sure I lost the facebook http likes and comments so I'd prefer to not use this plugin.
Writing the RewriteCond to prevent code from being executed when it's already https in a different way was the fix for me. I tried a lot of ways to check if the url was https or not with %{HTTPS} !on or %{HTTPS} off, but nothing worked. However, this comment helped me out.
The answer for me was rewriting the condition:
RewriteCond %{HTTP:X-Forwarded-Proto} !https
eventually my .htaccess file is just:
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://mysite.be/$1 [R,L]

WordPress Redirect all file downloads to subdomain

I have a new WordPress site, example.com, with the old Drupal site archived at archive.example.org. Many files on the old site had a URL like so (ex: example.org/files/foo.pdf), but all those links out there in the internet are breaking because all those file downloads need to be redirected to archive.example.org/files/foo.pdf.
Can creating redirects (I'm guessing .htaccess is the best bet) work for file downloads as well? Is there a simple redirect to send all old links to the archive subdomain?
I have tried:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/files/
RewriteRule ^ http://archive.example.org%{REQUEST_URI} [R,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
...with no luck so far.
Thanks for any help!
If you want to redirect all files/* requests to the new domain and keep everything else from WordPress, you need a condition for the rule, which checks for files
RewriteCond %{REQUEST_URI} ^/files/
RewriteRule ^ http://archive.example.com%{REQUEST_URI} [R,L]
When everything works as it should, you may replace R with R=301. Never test with R=301.

Categories