How relative link in href working? - url

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.

Related

Canonical URL formatting issue causes Facebook to interpret mobile URL as a different 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)

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.

Submit webform via URL only?

I'm not really sure this belongs here, so instead of downvoting just lemme know if so and I'll quickly move it on.
Anyway, there is a website that has a search page, that when hitting the search button it doesn't include the search query in the URL.
After searching for something, the page is redirected to ssearch.asp, but as said, the query isn't there.
My question is if there is a way to submit the search values solely via URL.
I was wondering if there is a way to fake the search-submit button and post the search term
via URL according to form field names.
The name of the input box is search, so I tried this URL: http://www.torec.net/ssearch.asp?search=query, but it doesn't work, the server returns:
server error.
Just to be clear, I'm not looking for a server-side solution, and actually nor for a HTML solution, I just want to be able to paste a plain old URL in my browsers address bar and be there.
Is this possible?
Update
This link doesn't work:
http://www.torec.net/ssearch.asp?search=dark&page=1
While this one does:
http://www.torec.net/ssearch.asp?search=dark&page=2
Any way to bypass this?
Sometimes servers conflate GET and POST parameters, as in PHP $_REQUEST hash. However, normally they are separate - and a server that expects its parameters in multipart/form-data might not look at URL at all. In such a case, as it seems to be here, you have to construct a POST request. On the client side you can do it through AJAX or through constructing and posting a form; on the server side, you can use curl, or a library. You did not say what you want to use it for (and where you want to use it), so you just get the general answer, I'm afraid.
EDIT: Here is the JavaScript semi-solution. You have to already be on some page (i.e. can't use it on _blank), and I'm not sure if it works on all browsers.
javascript:d=document;f=d.createElement("form");h=d.createElement("input");f.setAttribute("method","post");f.setAttribute("enctype","application/x-www-form-urlencoded");f.setAttribute("action","http://www.torec.net/ssearch.asp");h.setAttribute("type","hidden");h.setAttribute("name","search");h.setAttribute("value","query");f.appendChild(h);d.body.appendChild(f);f.submit();
Edit: It is not possible to create a link directly to the first page. However, you can easily send a user to the first page by by creating a form:
<form id="postForm" method="post" action="http://www.example.com/search">
<input type="text" name="search" value="q">
</form>
And then submitting the form whenever the user clicks a psuedo-link:
document.getElementById("postForm").submit();
This can also be done by typing JavaScript code into the address bar:
javascript:a=document.createElement("form");a.method="POST";a.action="http://www.torec.net/‌​ssearch.asp?search=dark&page=2";i=document.createElement("input");i.name="search";i.value="q";a.appendChild(inpu‌​t);a.submit();

pinterest link not working?

trying to create a pinterest link with javascript. It opens up pinterest, shows the correct images and description but when i click PIN IN it just refreshes and doesn't pin it.
Creating a custom link and heres a URL created that i think should be working -
http://pinterest.com/pin/create/button/?url=http%3A%2F%2Fsandbox.modernactivity.co.uk%2Findependent_02%2F%3Fattachment_id%3D743&media=http%3A%2F%2Fsandbox.modernactivity.co.uk%2Findependent_02%2Fwp-content%2Fuploads%2F2012%2F06%2FBBC%20-%20MEAT-NEW%20WEBSITE%20TEST%204%3A3%20to%2016%3A9%20cropping-743-still-150x84.jpg&description=Independent%20Films%2C%20%E2%80%98Meat%E2%80%99&ref=http%3A%2F%2Fsandbox.modernactivity.co.uk%2Findependent_02%2Fdirectors%2Fdaniel-levi%2Fshowreels%2Flive-action%2Fvideo%2F743%2F%23
Anyone know what might be wrong?
best, Dan.
Okay.. Let me start with a disclaimer. This answer might not even be right, but it did work for me. I had the same problem and my URL has lots of '+' in it.. which the URL encoded equivalent for a ' '. So, essentially pinterest seems to have a problem "pinning" them, although there seems to be no problem in rendering them...
Your URI seems to have a lot of spaces too..
so, if the URI is in your control, you may
Create the uri after URLEncoding them
Make sure that spaces and such like dont appear on the URI.
Looking through my IIS Logs I noticed that Pinterest was redirecting users to my website without a leading http:// even if specified in the address, this seems to be causing the error for me. Unsure how to fix this in IIS, but thought I'd throw you a clue I found.

Strange google result listing, invalid URL created

Would be great if you guys could shed some light on this, has baffled me:
I was asked by a client if I could try and make the search term for his comedy night "sketchercise" put his website top of the Google ranking. I simply changed the title tag of the header for the whole site from "Allnutt and Simpson" to "Allnutt and Simpson - Sketchercise # Ginglik - Sketch Duo". It did the trick and now the site comes up top of the Google listing when typing in "sketchercise". However, it gives off this very strange link:
http://www.allnuttandsimpson.com/index.php/videos/
This is the link to the google search result too:
http://www.google.co.uk/search?sourceid=chrome&ie=UTF-8&q=sketchercise
This link is invalid, it doesn't make any sense. I guess it has something to do with the use of hash tags and the AJAX driven site, but before I changed the title tag, it linked to the site fine using the # tags. What is the deal with this slash?
The strangest part is that the valid URL for the videos page on that site is /index.php#vidspics, I have never used the word "videos" in a url!
If anyone can explain the cause of this or just help me stop it from happening, I'd be very grateful. I realise that this is an SEO question and I hate that stuff generally, but I hope you can see this is a bit of a strange case!
Just to compare, if you google "allnutt and simpson" it works just fine links to the site and all of it's pages absolutely fine as .php pages (and then my JS converts them to hash tags to keep things clean)
It's because there must be a folder called 'videos' under your hosted files, use an FTP client and check this.
Google crawls every folder and file unless you tell him not to do this, look for robot.txt files to learn how to avoid indexation.
Also ask google to remove that result when you solve this.
Finally that behaviour is not related with hash tags, these are just references to javascript in order to display the appropiate content in you webpage.
Not sure why its posted like this but the only way to stop that page from appearing is using a google webmaster account for this website and make sure the crawlers can't find this link anymore. The alternative is have the site admin put this tag, <META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"> , in the header when isset($_REQUEST(videos)) is true.
The slash in the address is the parsed form of www.allnuttandsimpson.com/index.php?=videos. You can have the web server change all the php parameters into slashes to make the links look pretty.
Best option for correct results is to create a sitemap and submit it to https://www.google.com/webmasters/tools/ for that site. You will need access.
Oh forgot, the sitemap will make google see all the pages you want it to post, use this for the major pages like those in the main menu. To remove links you don't want requires a robots.txt in the main directory of the site.

Resources