How do I link to a URL that contains encoded forward slash? - html

Here's a page at the URL http://www.last.fm/music/45+King%2FTake+6
If I link to it in a page, using this HTML:
Link
then the browser 404s because it ends up here, at http://www.last.fm/music/45+King/Take+6. i.e., the %2F is decoded to /.
Why does that decoding happen? Why does a URL I can successfully paste into the browser not work as a link in a page? I feel like I'm going mad...

I noticed the "Here's a page" link in my question was working fine, while my link in a local static HTML file wasn't... that was confusing.
The difference is that locally my link was to the last.fm domain, rather than www.last.fm.
So, the link to last.fm redirects to the www.last.fm version, and in that redirection the %2F is decoded.
So I just need to link to www.last.fm instead!

Related

HTML Link not redirecting correctly - its navigating to www.oldpage.com/http://www.google.com?

Any one got any ideas why this is happening?
My html quite clearly is
www.google.com
However, when I click it, I am navigated to the incorrect URL.
In my case to -- http://localhost:8000/profile/1/www.google.com
Then the link is actually working. But the URL is wrong. You're using this URL:
"www.google.com"
But a browser has no way of knowing that this is another website. Structurally it's no different than, say, this:
"www.index.html"
Which is a perfectly valid name for a resource on your website.
To tell the browser that this should go to another website, include the protocol:
"http://www.google.com"
Or at least the // at the start to default to whatever the current page's protocol is:
"//www.google.com"
The URL You are using is
www.google.com
Which will not redirect to the site, You have to use it like this:
https://www.google.com
Ex.:
Working URL<br>
Not Working URL

URL in HTML and URL for desired link are not the same

I am working with mining some links from a Chinese academic article database.
It appears that when I refresh the page to an article I'm looking at, or simply copy and paste a url, the url redirects to the database's home page rather than the article.
For example, the following link goes to my search results:
http://search.cnki.net/search.aspx?q=%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD
The first article's individual url is:
http://www.cnki.net/kcms/detail/detail.aspx?dbcode=CJFQ&dbName=CJFQ2016&FileName=KJDB201615009&v=&uid=
However, if you try to directly click on the article link or refresh the article page, it redirects to the database home page. Why is this happening? Is there any way to get a "stable" url to these articles?
One detail that may matter, although I'm not sure, is that the url in the HTML code to the individual articles is also different.
<a href="http://epub.cnki.net/grid2008/brief/detailj.aspx?filename=KJDB201615009&dbname=CJFDLAST2016" target="_blank">
It's not really up to you.
The website you are referring checks if the link you are opening is a direct link or was opened from another page on the same website.
This is probably to prevent embedding links of this website in other websites.
In short, it does not allow direct links to its articles.
You can see it by examining the header returned from the request.
Instead of 200 OK you get 302.
Which tells the browser to redirect to another location.
You can try and fool the website by adding a "Referer" header to your request.
If you look at the header
that works you'll see that there is one.
I did not try but I'm pretty sure it will work.

Link is removing Http header

I am trying to do a simple thing , navigate to an external url
Class Books
However I am getting a 404 because the Http// portion is being deleted I am not sure if this is an mvc thing or html thing. Here is link http://18.217.228.108/angularapp1.
Here is a link to a screen shot of me accessing url
https://gyazo.com/455b01f1ceded24f9b4ce6c58b0e10e1
Curious-programmer,
You must navigate using an absolute URL just when it is out of your domain such as https://www.amazon.com/
However, I've noticed that you are trying to navegate to a link inside your own domain using absolute URL when you must use relative URL like:
Class Books
Try
Anchor Test
and then try keying http://18.217.228.108/angularapp1/book/ into your browser url.
The link you are using is actually 404.
Based on the link given in updated question:
The new link you've given is an html page (which you can navigate to in the "normal way"). It links to an angular app with an anchor "Books". Clicking on "Books", whilst attaching "book/" to the url in the browser (the url you're trying to link to in your original question), is intercepted by the script and actually navigates to:
http://13.59.126.130/BuellerWebApi_deploy/api/book/getAll
which returns a Json object containing data to display on the same page.
(Your concern about the removal of the http:// in the anchor is a red-herring (try navigating to http://www.bbc.com - you will see www.bbc.com in the browser url). It's the way your app has been configured.)
So, as things stand, navigating to the anchor in your original question, whilst appearing to be a valid url, actually is not. Its a 404.

Why are my URLs messed up by Facebook?

The link to certain pages on a site I've written looks like this:
http://myhymnal.net/2/be-thou-my-vision
That would be the id and a slug. When I paste this URL into the Facebook post field, the URL it ends up fetching an "example" of is the following:
http://myhymnal.net/2/2/be-thou-my-vision
Could anyone help me figure out where that extra 2/ comes from? I don't understand it.
Findings
The URL I paste in is http://myhymnal.net/2/be-thou-my-vision and works fine in the browser.
The base href is set to http://myhymnal.net/ and I have set the canonical to 2/be-thou-my-vision, which is relative to the base URL and should work fine. Although I suppose this maybe could be what's messing it up?
Other than that I really have no clue... :(
Look at Facebook's Debug Tool - you're setting the canonical URL relative to the current directory, not the site root - facebook is then fetching http://myhymnal.net/2/2/be-thou-my-vision
Use a fully qualified URL for the canonical URL

Link to Homepage is forwardslash

Im have the default routing and write a link to the Homepage in my view
Link
The generated content is a forward slash.
Link
This link works in Firefox but in IE8 no request is sent to the server when the link is clicked.
Is a forward slash a valid content in a link?
EDIT:
OMG, I tried to have an image inside the link but actually put an input type image there. The funny think is that it worked in Firefox.
Thats how my linked looked like:
<input type="image" src="/Images/buttons/btn_buy_more.gif" alt="" />
I will leave this question here so you have somebody to laugh about.
Url.Action isn't supposed to send a request to the server. It just generates a link address. Look at the generated URI in the HTML source of the rendered page. I'll bet it's the same in both browsers.
What I think you mean is that clicking the link is behaving differently for you. To figure out why, use Fiddler to examine the request the browser sends and the server's response.