URL Rewriting and Facebook link information retrieval - facebook

I am developing a website and I want to integrate it with Facebook, allowing users to share the pages of my website in their FB walls. My problem is explained in the following lines and my question is at the end.
I am using the following URL rewriting rule in my .htaccess file:
RewriteRule ^([a-zA-Z0-9_-]+)\/?([a-zA-Z0-9_-]+)\/?$ index.php?p1=$1&p2=$2
That means it will rewrite anything like: http://address/parameter1/parameter2 as http://address/index.php?p1=parameter1&p2=parameter2.
When I post http://address/parameter1/parameter2 on FB, it will only show the rewritten URL under that URL.
I posted http://address/index.php?p1=parameter1&p2=parameter2 on FB, and it will show the information I want it to show, the ones I have put in the meta tags.
I tried debugging http://address/parameter1/parameter2 on the FB debugger (http://developers.facebook.com/tools/debug), I will get the error:
"The page at ... could not be reached because the server returned status code 400."
Is there any way I can correct that? That is, actually making the dynamic link behave like a static link, and making that transparent to anyone who links it?
Edit:
This change in the rewrite rule should solve the problem:
RewriteRule ^([a-z0-9_-]+)/?([a-z0-9_-]+)/?$ index.php?p1$1&p2=$2 [L,NC]
I also changed the redirects in PHP that I was doing.
And that solved my problem.

I have similar issue to yours, except I manage url rewriting with php dynamically.
I am currently a web host that do not allow url rewriting through htaccess (free.fr)
dynamic standard url is handled properly. But not rewrited url.
How would you get rid of this, considering header status code?
What I could do is doing a redirect instead of include script which produce html output code.
Just have to tell the handler to switch between include and redirect, thanks to a special added param in the url.
But it's not a pretty solution.

Related

Facebook share ignores custom query string parameters

I try to share an URL that contains query parameter in FB.
Here is my share link
Sharing works but my custom query parameter is gone and replaced with facebook query parameters in the facebook timeline something like here
The same problem when FB.ui({ method: 'share',... is used.
It worked well on previous version of facebook sharing sharer.php but it's deprecated now and I have no idea how to make current share work.
We faced same problem. We instead used Feed Dialog that works fine. The irony is that if you read on facebook's developer's site Facebook is recommending us using Share Dialog in place of Feed dialog however, Share dialog does not work as expected.
Here is the link to get more information on Feed dialog
https://developers.facebook.com/docs/sharing/reference/feed-dialog/v2.2
Personally i like Feed dialog more the share cause it gives you some additional properties to manage how dialog should appear
i assume you solved your problem in a different way already but i have found a solution for this. Just in case somebody else comes across this question.
Facebook strips the parameters only when it is more or less sure that the file is an php file.
So for http://example.com/?test=1
or http://example.com/index.php?test=1
the parameters are removed.
But if you make it look like a normal html file, it works:
http://example.com/whatever.htm?test=1
for example is posted with the parameters.
Of course you can use some simple mod_rewrite Rule to redirect the request to the original php file:
RewriteRule /whatever.htm(\?.*) /index.php%1
(rule is untested but should work hopefully)

Tumblr share url

I've came across this page https://www.tumblr.com/examples/share/sharing-links-to-articles.html which shows a possible way to customly create a share URL for tumblr.
Simplified version of what they have:
Click to share
http://jsfiddle.net/m5ow6bhs/2/
This will take you to the log in page or straight to the share page if you're already logged in. However, if you change the http%3A%2F%2F part to a simple http:// it will now load to a "Not Found Page". http://jsfiddle.net/m5ow6bhs/3/ What the hell Tumblr?
Do you guys have any idea what's going on or what's the correct code to share something to Tumblr?
Cheers.
As with most share services, the URL should be passed as an encoded string. This supports the OPs comments about http%3A%2F%2F(encoded) and http:// (raw).
Tumblr provides variable transformations in the theme operators to handle encoding, but sadly it doesn't work with custom variables.
One quick solution is to drop the http:// part. Example: http://jsfiddle.net/L9jd8dhz/
I have discovered as of recently that the share URL needs to be updated as such:
https://www.tumblr.com/widgets/share/tool?shareSource=legacy&canonicalUrl=<-urlencode(share_url)->&posttype=link
The &posttype= seems to be a new requirement to make the share work correctly.

301 redirect chain in html

I have searched on the internet and on your forum but just cannot find the code to write a chain redirect.
I understand that it is not good practice to redirect more than 3 times but I need to redirect two pages in my website both which have already been redirected once before.
My website is in HTML and I did the previous redirects on the .htaccess file.
I would like to redirect a second time but cannot find how to write this, would it be:
RedirectPermanent /old-page.html http://www.website/folder/new-page.html http://www.website/folder/new-page-two.html
OR
RedirectPermanent /old-page.html http://www.website/folder/new-page.html /folder/new-page-two.html
or do I redirect directly from the original redirected page?
The first redirect was done about three years ago.
I also need to tell Google that some of my webpages do not exist anymore. Can I put a 410 coding on the same .htaccess page or do I need a separate one or do I just delete them and tell Google through my Sitemap.xml?
I would be so grateful for your help with these confusing questions.
Thanks
I understand that it is not good practice to redirect more than 3
times but I need to redirect two pages in my website both which have
already been redirected once before.
It’s not a “bad practice” issue as you are describing. If a user visits /old-page.html how exactly are they going to go to two URLs from that? Is there any site on the Internet you have ever seen that?
I am assuming you want to have two different redirects. Which you can do like this:
RedirectPermanent /old-page.html http://www.website/folder/new-page.html
And then on www.website you do this:
RedirectPermanent /folder/new-page.html /folder/new-page-two.html
I also need to tell Google that some of my webpages do not exist
anymore.
So if you have a page that doesn’t exist, it should return a 404 & Google will know that. So what is the issue? Unless you want to force requests to 404. Then you would do something like this for a page like bad-page.html to 404 on each request:
RewriteEngine on
RewriteRule ^/?bad-page\.html$ - [R=404]
But it seems like you have very simple issues that you are overcomplicating.

Workaround: site is www.example.com code incl. document.domain='example.com'

A customer site that I cannot change has the line document.domain = "example.com" while the site is at www.example.com.
The effect is that FaceBook Connect window login gets stuck after submitting username+password.
Firebug shows its in infinite loop inside dispatchmessage function, which gives perpetual exception:
Error: Permission denied for <http://www.example.com> to get property Window.FB from <http://example.com>
Any idea how to work around this? I prefer not to ask the customer to remove the document.domain='example.com'
It seems like a really bad idea to tell the visitor's browser that the website is being served from a particular domain, when it in fact is not. The best solution would be to change that line. I take it you don't want to change it because they have some client-side code that depends on this?
One workaround would be to change the Facebook application's Connect URL to http://example.com, since Facebook's JavaScript will think that is where it is being executed.

Can RSS readers follow redirects if the url of the feed changes?

We are migrating to a Sharepoint solution and our urls are changing slightly.
Are most RSS readers able to follow redirect links without breaking the feed and making an update manually?
Most of the documentation I'm reading says that this will work for major RSS readers.
I have read in some places that a lot of RSS readers will treat a 301 as a temporary redirect and not update its stored url. Any truth to this?
Assuming you are using a 301 redirect, I would say yes, since any reader worth its salt is built on a compliant HTTP library which will honor the 301 status code and follow the redirect.
Of course, it's not that hard to test with the reader of your choice.
Pretty much every RSS reader - major or minor - will update the feed URL when it encounters a 301 redirect.
In my (limited) experience, most applications will ignore the "permanent" part of a permanent redirect and execute the same logic they would use for a temporary redirect.
It may be necessary to make its site velindekserede about. What to do so to preserve PageRank, link popularity and traffic?
As I understand it, so the solution is called a 301 redirect. It tells search engines that the URL has been permanently moved. How a redirect should be done in a special way. At this link there are different options depending on what kind of server technology you use:
http://www.webconfs.com/how-to-redirect-a-webpage.php
I just tried it in practice. I use PHP itself on all my sites, so I used the PHP instructions:
I ripped all my old page for tags and content and put the small code snippet on the page. Prisoners of the new URL for the page, and saved it. Tested the page by typing the old URL and then redirects worked. To be absolutely sure that redirects are search engine friendly, I used this "Search Engine Friendly Redirect Checker":
http://www.webconfs.com/redirect-check.php
There no disagreement about how well the 301-redirect is working and whether it can transfer an entire site to a new domain (http://www.webmasterworld.com/link_deve ... 135964.htm), but people's experience says that it is good enough. You just make sure that the new URL has the content as the old page had