Why are my URLs messed up by Facebook? - html

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

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

Extracted URL not redirecting

I am looking at the following site: https://www.lg.com/us/press-release.
I need to get a link to go directly to the computers tab, and it needs to be a url.
I extracted and tried: https://www.lg.com/us/press-release#press-list5 however this still redirects.
Can someone tell me what the URL is to go directly to the computer tab please?
Thanks
I don't think a URL is going to work. I believe there's some Javascript at work here.
Why?
Before/Unclicked:
Computers
After/Clicked:
Computers
So once it's clicked, the list item has the active class added and the aria-selected attribute set to true. So a URL with a bookmark doesn't look like it'll work.

<a> link puts page name at end of url

Sorry if the title is confusing, I wasn't exactly sure how to word this.
Basically what I want to do is make a link, simple enough. The page is tylerofcinema.github.io and if I make a link to say, google.com the url that I get is tylerofcinema.github.io/google.com.
Code is in a repo here, let me know if there is any clarification needed.
Thanks, Diego
You did not include the protocol of the url, causing the href to think it needs to open a page in the same directory.
Try adding http:// (or https://) to your href and it will open the specified url.
<a target="_blank" href="https://tylerofcinema.github.io/r/twitter"><button class="homesmb">Twitter</button></a>
should be a simple syntax error.
My suggestion would be to change the url to the full address like http://www.google.com so that the browser understands you mean the actual google server and not something else. give it a try
just add // before the start of the link, it should work

Parsing relative links on a html page

I'm trying to parse a page to find all valid urls, but here is a problem. There are 3 types of links on a page: url (_http://site.com/dir/page.html), absolute uri (/dir/page.html) and relative uri (dir/page.html without starting slash). Probably i'm wrong about terminology, i'm not an html coder. But that's not the case in any way.
I need to find and collect all urls (i.e. _http://site.com/dir/subdir/page.html and so on). And here is the problem. If there is a page _http://site.com/dir/page.html with a link like link it's supposed to bring us to _http://site.com/dir/subdir/page.html. But if there is <base href="/"> in the head section of a page, same link leads to _http://site.com/subdir/page.html i.e. different from _http://site.com/dir/subdir/page.html.
The question is if there can be anything else in html code on a page that can influence target url.
Thanks in advance.
In HTML as such there is nothing else beside the href base You mentioned
What could become tricky and should be considered is that there might be linkage on page made by script execution, so things like window.location.href = something. This would be easy if the links are clearly stated, but they might be also computed by the script and then You could miss the link or mis-read it by using simple parsing.
Your problem is actually how url linking in html works, please read: http://www.webdevelopersnotes.com/design/relative_and_absolute_urls.php3 . So say you're in /admin/ and you need /admin/login.aspx . My relative URL is login.aspx, while my absolute is /admin/login.aspx make sense?
So basically what I'm saying is consider which directory your link is being served out of. That will determine the type and content of the url link to use.
Other than that, as stated already, jscript and server side code can also do linking.

Paths relative to the file location and NOT the url

**** EDIT: SOLVED HERE Relative paths from file for img, a and header ****
Somewhat new to web design.
I just finished creating a dynamic site. It can read domain/category, domain/category/this-article-about-x, all redirecting to domain/index.php and working well.
However, I quickly learned that whenever I used a relative path such as ./include, the relative path was taking in account the current URL, and not the actual url where the php file is at.
I have 2 questions that I couldn't answer when browsing the internet for a long time:
1) If domain/index.php is trying to show an image with ./thumbnails/science/image.jpg, it won't work if the actual url is domain/category/, but it WILL work if its just domain/category(no slash at the end). Why this inconsistency? The HTML code is showing the src to the image is the same on both cases.
2) My header has a dropdown menu with categories. Once its submitted, it will call itself (header.php), see which category the user chose and redirect to domain/category. All works well. You can then rechange the dropdown menu to another category and everything loads again. But again, if you access directly domain/cateory/ (with the slash at the end), the CSS won't load, the images won't load as said on question 1, and submitting the form will cause a problem because it will look for header.php on domain/category/, and not just on domain where the header.php file actually is.
I have successfully used dirname(FILE) to make sure my includes all work (as far as my testing has gone, no errors). But I could not use dirname(FILE) to generate links or images 'img src=' that will always point to the images regardless of the URL.
On localhost, the HTML is coming as img src=c:\path\htdocs\thumbnails\img, which is right, but the image does not display anyway. Same with the 'a href' links. Trying to create links with dirname(FILE) created links on localhost as c:\correctpath, but clicking on them did absolutely nothing. Also, using header with dirname(FILE) to handle the redirection from the dropdown menu caused it to cease working as well (but if I used ./ . dropDownMenuValue, it would again correctly change the url to domain/categoryChosen)
How can I use a consistent method for relative urls that allow me to work on localhost and then upload to my web host without the need make changes to the files, AND that works with dynamic websites that have pretty name urls through htaccess?
Thank you,
This is all very puzzling for me how getting a relative path from the current file path is being so hard and generating so many different issues, and why only include statements seem to work well with dirname(FILE)
Edit: http://board.phpbuilder.com/showthread.php?10374336-RESOLVED-mod_rewrite-for-SEO-Friendly-URLs-and-relative-path-issue-fixes
I've found this on other sites, but it requires you to change the base everytime you want to go from localhost to the web. I'm trying to avoid that. Clearly there has to be a simple way to do something so basic. I can't believe google and everybody else are changing paths when they are ready to make something live.
You should just always use absolute paths for public files like media. If you don't want to do that for some reason or your site is just too involved at this point you'll have to create rewrite rules for the other file types so they can also be included from the correct path.