Canonical URL formatting issue causes Facebook to interpret mobile URL as a different URL - url

I need to format this canonical URL and I cant figure out how! I've looked around the web and this site a lot and I've realized that I need a specific answer.
Problem Description:
My BLOG's desktop view has (say) URL: www.x.com/page.html
The same page in mobile view URL would be: www.x.com/page.html?m=1
Its all good and dandy to this point, but the problem comes when I use facebook comments with this. It parses url based on this: www.x.com/page.html
So, it is identifying ?m=1 in the end of the first URL as an entirely different URL.
i.e
It is treating those two URL as different
Both of them are URL for the same page and I want them to be treated the same
Could anyone provide me a way to check if the loading page is ?m=1 and if it is ?m=1 then remove the ?m=1 when sending it to facebook?
I WOULD GREATLY APPRECIATE IT IF THE SOLUTION IS INLINE if it is not inline, oh well, I just need a solution right now.
Current code snippet used is this:
<fb:comments colorscheme='light' expr:href='data:post.url' expr:title='data:post.title' expr:xid='data:post.id' height='110' width='560'/>
Let me break the question into small parts(incase someone is not a native speaker and wants to help/learn about this problem)
I want to detect if the loading page has ?m=1 in its URL or not. The canonical URL for this is data:post.url applied as
expr:href='data:post.url'
If a ?m=1 is detected from data:post.URL , I want to remove it and send the remaining URL into expr:href= so that both my URLs
are identified the same when my website displays facebook comments.
Click the image link below to look at this image please. This is the same URL but the
comments are being sent to me as if they're from different URLs. I
want them to appear under the same thread.
This is it--> http://i.stack.imgur.com/M7fK2.png
I haven't found this particular answer anywhere and I am hopeful that
some creative solutions will pop out in this site!

In your code
<fb:comments colorscheme='light' expr:href='data:post.url' expr:title='data:post.title' expr:xid='data:post.id' height='110' width='560'/>
Use data:post.canonicalUrl instead of data:post.url
This is the Blogger's layout tag for getting the Canonical URL of a blog post (This will always default to the blogspot.com domain, so there won't be ccTLD issues as well)

Related

Error parsing input URL, no data was cached, or no data was scraped. (2015)

i share websites content through Facebook Open Graph on Facebook.
But some of the URL give the above error (though the url of posts and its images are correct).
in example.
this url works:
http://dehmazang.org/post?id=00061&cat=articles
or if i change its category(articles) to (roznigar)
it also works:
and if i just change its category(articles) to (goftago)
it doesn't work
and also changing to some other categories doesn't work.
I don't really know is there fault with website or Facebook.
Stackoverflow is a place for people writing their own code, webapps might be a better place to ask, or superuser.stackexchange.com
Facebook's scraper works the same way with all website, it's about the setup on their individual website, put the links into http://developers.facebook. com/tools/debug

Opencart: Remove page ID path from URL

I'm trying to make my site more SEO friendly and I' noticing that whenever I go to an product through either a tag or a different page (2,3,4 ect) that it adds it to the URL.
For example:
www.wisdomsurvival.com/Guardian-Survival-kit/culinary-can-of-preparedness-seeds.html?page=2
I would like to remove ?page=2 from the path
Opencart 1.5.4
Any help would be greatly appreciated.
EDIT: My main goal is to have one URL for each page instead of multiple paths. For example:
http://www.wisdomsurvival.com/person-guardian-preparedness-package-camping-bug-out
http://www.wisdomsurvival.com/camping-and-bug-out/person-guardian-preparedness-package-camping-bug-out
The first URL is a direct link, the second comes from clicking from a category, the third (not shown because I can only post 2 links) comes from clicking from a subcategory and the fourth (also not shown) from a manufacturer list.
I need to have them all either redirect to the first URL or just go directly to the first URL without redirecting, along with any other URLS such as the ones that have the page ID path or tag path.
I recognise that theme :-)
Where is the ?page=2 coming from as the link works perfectly without it. You need to trace the source of the link. First try the template views and see if it is a simple link edit in the layout that will accomplish what you need.
If not you may find the information is coded in the controller if it is being dynamically generated. Again you should be able to edit the code that generates the link there.
If not you may find that it is in a model that is being called. Again, just find the model and edit the link structure you find there.
The url on your page will only be a reflection of the url you generated somewhere else in order for the link to be followed in the first place.
Usually when I am building with opencart I find the theme modules are often not coded very well in terms of SEO. Fortunately with opencart these things are usually very easy to remedy.
Top trick -> I often stick additional bits into my urls that have no impact on the page generated but Google picks up on as keywords anyway.
If you post your code if you are having problems reformatting the link formats I will have a look for you,
Hope that helps,
Paul.

Is there a way I can include the current webpage url?

I have a webpage that I want people to fill information out on and then a response emailed to me with that information. Is there a way that I can include the url in the email from that page using html?
I have no clue how to start this. I saw a similar question here: Get current webpage URL
but I don't understand how to turn the src: url to the one of the page I am currently on. It seems like I should be able to reference it, but I am unsure how.
Thanks
This is not possible with straight html. You can use Javascript to change the src attribute:
document.getElementById("myElement").setAttribute("src", window.location.href);
In this example, it's assumed that you are attempting to change the src attribute of an element with the id "myElement".
See this question. To get the webpage URL with JavaScript, you can use document.URL. You can then use it for what you want.

How relative link in href working?

I have a problem relating to relative links in href. To make a long story short, I think an example is the best way to get what's going on.
On tinhte.vn/threads/300021/, it is a discussion forum, to go to the page 2, we click on [2].
I view source code of [2], its content is 2.
If I do not misunderstand about relative links, this will append threads/30021/page-2 after the current link, which is tinhte.vn/threads/30021/, and we have the link like this:
tinhte.vn/threads/300021/threads/300012/page-2
But in practice, when I do in the browser, mine is chrome, the link is:
tinhte.vn/threads/300012/page-2
Anyone please explain why?
Sorry, due to the spam prevention, I cannot post direct link.
Thanks in advance.
The link will correctly go to tinhte.vn/threads/300021/threads/300012/page-2 as you guessed. However, looking at the response from a request to that url we can see that the page redirects to another url. I used web-sniffer to quickly see the raw response from the server.
The interesting part of the response is this:
<input type="hidden" name="redirect" value="/threads/300021/page-2"/>
The browser will react to this and navigate to the specified URL. Hence the observed behaviour.
Read more about redirects here.

Hide website filenames in URL

I would like to hide the webpage name in the url and only display either the domain name or parts of it.
For example:
I have a website called "MyWebSite". The url is: localhost:8080/mywebsite/welcome.xhtml. I would like to display only the "localhost:8080/mywebsite/".
However if the page is at, for example, localhost:8080/mywebsite/restricted/restricted.xhtml then I would like to display localhost:8080/mywebsite/restricted/.
I believe this can be done in the web.xml file.
I believe that you want URL rewriting. Check out this link: http://en.wikipedia.org/wiki/Rewrite_engine - there are many approaches to URL rewriting, you need to decide what is appropriate for you. Some of the approaches do make use of the web.config file.
You can do this in several ways. The one I see most is to have a "front door" called a rewrite engine that parses the URL dynamically to internally redirect the request, without exposing details about how that might happen as you would see if you used simple query strings, etc. This allows the URL you specify to be digested into a request for a master page with specific content, instead of just looking up a physical page at that location to serve.
The StackExchange sites do this so that you can link to a question in a semi-permanent fashion (and thus can use search engines with crawlers that log these URLs) without them having to have a real page in the file system for every question that's ever been asked (we're up to 9,387,788 questions as of this one).

Resources