Recent days I got an issue with Facebook Application, In that application used .htaccess to redirect the urls, If we want to use this app then we should have secured url i.e. ‘https’, Before purchase the SSL for our domain. We can check our app by changing the security permission in https://www.facebook.com/settings?tab=security , we can see the flow to check that how can we change that.

More tips on .htaccess by Anil Kumar Panigrahi
Change the settings in Facebook
Screen #1

More tips on .htaccess – Facebook Security Settings Screen – by Anil Kumar Panigrahi
Screen #2

More tips on .htaccess – Facebook Security Settings Screen – by Anil Kumar Panigrahi
After changing that we can access the our page app without ‘https’, In this way we can approach our application will work. If you access the application with ‘https’ then you will get blank or error will get.
After purchase the SSL certificate for your site and we can force to get the website with ‘https’ by adding below in your .htaccess file
1 2 3 4 5 6 7 8 | <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} !^on$ RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [QSA,L] </IfModule> |
By adding above code in your website, we will force to get/redirect with ‘https’. Then will effect to your Facebook application too. If you change the security settings to disable, then your application we will get the Facebook page id.
1 | $FBsignedRequest = $Facebook->getSignedRequest(); |
In the above code $FBsignedRequest will get the NULL.
because in the Facebook application, url will redirect to http://domain.com/fbapp/ to https://domain.com/fbapp/ then we loose the posted values i.e. getSignedRequest which from Facebook API, After research on the same issue about 4 hours, finally I got solutions for it.
Add the below code for your .htaccess file
1 2 3 4 5 6 7 8 | <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} !^on$ RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=307,L] RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [QSA,L] </IfModule> |
In this also URL will redirect but with posted values i.e. getSignedRequest
Recently my friend Srinivas Tamada posted regarding Create Custom Facebook Application and regarding .htaccess Htaccess File Tutorial and Tips
This post is extensions to those posts.
0 Comments