I've uploaded several files to my server and it's really quite baffling. The home page is saved as index.html, and when I type in the URL of said page it miraculously, and quite successfully shows the right page. What about my other pages? I have linked to them from the home page with the following code:
About Us
How does my html file, presumably called about.html, supposed to know that its URL is "http://www.example.com/about/"? I am dubbing this "The Unanswered Question" because I have looked at numerous examples of metadata and there is nothing about specifying the URL of a page.
It depends on what type of server you are running.
Static web servers
If it is the simplest kind of static file server with no URL aliasing or rewriting then URLs will map directly to files:
If your "web root" was /home/youruser/www/, then that means:
http://www.example.com -> /home/youruser/www/
And any paths (everything after the domain name) translate directly to paths under that web root:
http://www.example.com/about.html -> /home/youruser/www/about.html
Usually web servers will look automatically for an "index.html" file if no file is specified (i.e. the URL ends in a /):
http://www.example.com/ -> /home/youruser/www/index.html
http://www.example.com/about/ -> /home/youruser/www/about/index.html
In Apache, the filename searched for is configurable with the DirectoryIndex directive:
DirectoryIndex index.html index.txt /cgi-bin/index.pl
That means that every request to a path that ends in a / (and to add yet another rule, under some common settings it will automatically append a / if the path is the name of a directory, for example 'about'):
http://www.example.com/ -> /home/youruser/www/index.html
-> or /home/youruser/www/index.txt
-> or /home/youruser/www/cgi-bin/index.pl
Web servers with path interpretation
There are too many different types of servers which perform this functionality to list them all, but the basic idea is that a request to the server is captured by a program and then the program decides what to output based on the path.
For example, a program might perform different routes for basic matching rules:
*.(gif|jpg|css|js) -> look for and return the file from /home/user/static
blog/* -> send to a "blog" program to generate the resulting page
using a combination of templates and database resources
Examples include:
Python
Java Servlets
Apache mod_rewrites (used by Wordpress, etc.)
Links in HTML pages
Finally, the links in the HTML pages just change the URL of the location bar. The behavior of an HTML link is the same regardless of what exists on the server. And the server, in turn, only responds to HTTP requests and only produces resources (HTML, images, CSS, JavaScript, etc.), which your browser consumes. The server only serves those resources and does not have any special behavioral link with them.
Absolute URLs are those that start with a scheme (such as http: as you have done). The whole content of the location bar will be replaced with this when the user clicks the link.
Domain relative URLs are those that start with a forward slash (/). Everything after the domain name will be replaced with the contents of this link.
Relative URLs are everything else. Everything after the last directory (/) in the URL will be replaced with the contents of this link.
Examples:
My page on "mydomain.com" can link to your site using the Example.com about just as you have done.
If I change my links to about then it will link to mydomain.com instead.
An answer your question
How does my html file, presumably called about.html, supposed to know that its URL is "http://www.example.com/about/"?
First, the file itself has no idea what its URL is. Unless:
the HTML was dynamically generated using a program. Most server-side languages provide a way to get this.
after the page is served, client-side scripts can also detect the current URL
Second, if the URL is /about and the file is actually about.html then you probably have some kind of rewriting going on. Remember that paths, in their simplest, are literal translations and /about is not the same as about.html.
Just use /about.html to link to the page
Theoretically, it's better for URLs in your documents to be relative, so that you don't have to change them in the event you change the domain or the files location.
For example, if you move it from localhost to your hosted server.
In your example, instead of www.example.com/about.html use /about.html.
Given the link above you would need a about page named index.html located in a directory named about for your example to work. That is however not common practice.
I'm a bit confused, but here is some information. Any file named "index" is the default display page for any directory(folder) when trying to view that directory.
All files in a folder are always relative to that directory. So if your link is in a file, within a different directory, then you must type in that directory along with the file. If it is the same directory, then there is no need to type in that directory, just the file name.
about.html doesn't know what it's URL is, its the index.html file that calls your about.html file.
When you're in any given directory, linking to other pages within that directory is done via a simple relative link:
About Us
Moving up a directory, assuming you're in a sub folder (users) perhaps you can use the .. operator to navigate up one directory:
About Us
In your case your about page is in the same directory as the page you're linking from so it just goes to the right page.
Additionally (and I think this may be what you're asking) if you have:
about.html
about.php
about.phtml
about.jpg
for example, and you visit http://www.yoursite.com/about it will automatically bring up the html page and the other pages should be referenced explicitly somewhere if you want them to be used.
Related
If I want to load the homepage of https://medium.com/ by typing the exact index.html file address into my browser, how would I do that? Or is it not possible?
https://medium.com/index.html gives me a 404 error. Also curious how I would do this more broadly with any webpage for which my browser is displaying a url that does not end in .html.
Common static websites hosted just as files somewhere usually have an index.html document which can be resolved either directly or is normally loaded when no particular document is specified so https://example.com/ and https://example.com/index.html both work.
But this is not how most webs work. Pages can be dynamically generated server side, you just send a request to the server and if the path matches some server operation it will create a response for you. Unless https://example.com/ returns documents from a directory using something classic like the Apache Web Server set to serve static files from a directory, it won't work.
There is no general way to know what, if any, URLs for a given website resolve to duplicates of the homepage (or any other page).
Dynamically generated sites, in particular, tend not to have alternative URLs for pages.
I imported some HTML, JS and image files into Resources->Files of my database.
In the index file, I have:
<base href = "/client/hd">
<img src= "/client/hd/images/imagefile.png">
But upon checking the image source, it's accessing the URL below:
http://his90/client/hd/images/imagefile.png excluding the location of database and database name (ex. /fi20/fi20test.nsf)
It should be http://his90/fi20/fi20test.nsf/client/hd/images/imagefile.png
May I ask for a solution for this? HTML files are just imported in the Resource, no forms or views were created.
That is because you start the link URL with a /. That will start at te root of the web server. If you remove it, the link URL will start from your current location, and (assuming that the index file has the URL http://his90/fi20/fi20test.nsf/index.html) you should get the correct link URL.
You can also create a substitution rule for the internet site (using Domino Administrator, under Configuration, Web, Internet Sites). You then substitute / with /fi20/fi20test.nsf/ and it should also work.
Talk to your administrator about which is the proper way in your specific case.
Also, assuming you add the image as an image resource called imagefile.png, the URL should be just http://his90/fi20/fi20test.nsf/imagefile.png, no file structure.
What I sometimes do is to create web substitution rules for /images/, /pages/ and /agents/ to all point to the .nsf file itself. Then in the HTML code (and Javascript) I can reference the different resources with /images/imagefile.png or /agents/getUserList.json, etc. Makes the code much easier to read and understand.
I have a site:
example.com/index.html
There is a subfolder (subsite):
example.com/subsite/different_index.html
different_index.html contains a form:
<FORM action="different_index.html?action=edit">
However, when the submit input button on this form is clicked, the page attempts to redirect to:
example.com/subsite/subsite/different_index.html
I've tried making the form action the exact url needed:
<FORM action="example.com/subsite/different_index.html?action=edit"> <!-- target self -->
But I still get:
example.com/subsite/subsite/different_index.html
subsite is duplicated within the URL.
Any ideas how to correctly target this form?
The fact that you have a form is actually irrelevant. What you are really asking is about referencing resources and the rules are pretty simple:
If the resource you need is part of the same web site (not talking about folder structure here, talking about domain), you should use relative paths, where:
a. fileName.ext is all you need if the resource is in the same folder as the currently loaded document.
b. folderName/fileName.ext is what you need if the file you need is in a sub-folder of the current folder that the loaded document is in.
c. ../fileName.ext is what to use if the file you need is one directory higher than the current document's folder. The ../ can be repeated if you need to go up more than one level (i.e. ../../fileName.ext).
d. /fileNameext or /folderName/fileName.ext indicates that the file or folder specified should be found starting from the root of the web site, regardless of where the current document is.
If the resource you need is located on another domain, you'd use an Absolute Path (http://something.something/file.ext).
a. DO NOT use absolute paths for local resources! This may work but causes the domain name to have to be resolved again, resulting in a longer load time.
WARNING: Different servers have different configurations and requirements that may affect whether these reference rules work or not. For example, GoDaddy web hosting provides an "httpDocs" folder at the root of a web site. You don't have to use it, but that's where their servers expect the site's content to be placed. Not following those rules result in relative paths not working. Additionally, many servers are hosted on operating systems the have case-sensitive file systems, so always refer to files and folders in the same case that is actually used. Again, not doing this may work for you locally, while you develop (because you haven't moved the files to the remote server yet), but don't let that lull you into thinking that case doesn't matter.
I have seen a lot of people been using that file name for their HTML files. I wonder why? I'm kind of new to HTML, I haven't learned much, but when I name my HTML files, I name them whatever I want. When I have been searching up examples of HTML, I have found they name it index.html. Why?
I have seen a lot of people been using that file name for their HTML files
You would typically use that name for one of your page, and it would usually be the home page.
When you arrive a website, for example www.website.com, you're not pointing to a file (like you would be if you typed www.website.com/about.html), you're pointing to a directory listing of all the files.
The webserver will try to serve a file, typically called index.html or index.php by default, but it could be something different, and it's configurable by editing your webserver's config files.
If the server doesn't find any file to serve (because you didn't include an index.html file or because you renamed it without editing the server's config) you will see a listing of the files, which is rarely the desired behavior, especially at the root of a website.
Generally the contents of index.html will be returned when just the directory is requested.
e.g. http://example.com/index.html is returned for a request for http://example.com
This is merely convention and is usually configurable.
Here is my take: It was likely named 'index' in the original internet because it is the 'indexing page' that directs to the sub pages, and you would go back to the index page to go to another page. This was before images and search engines. Later it got more advanced with a menu on all pages. This is how I remember it, but it's a long time ago.
https://twitter.com/PresidentUSW1/status/1442236777293496325?s=20
The default landing page of many Web servers defaults to index.html or default.htm and either way it's simply a start page. It's not necessary at all.
So I have a Site created with Typo3. I also have a domain which is linked to the folder of the Typo3 Installation. www.example.org
I created a Subdomain and linked it to the same folder and used the Main Domain for something else.
But now everything on the Subdomain still has the URL Structure of the main site so when I open up sub.example.org all the Links and Images still have the URL from www.example.org/...
I exported the Database and replaced every URL with notepad++ and imported it again. But that didnt change anything. What do I do wrong?
There are two (three with realurl) places where you need to look if changing the domain of a TYPO3 site, if everything is done by the book and noone hardcoded the domain all over the place or something.
Usually you do not need to work in the database directly.
After doing the changes, make sure to clear the caches (install tool in 6.2+, "all caches" in earlier versions).
First:
There are two TypoScript settings that influence the generated URL: config.baseURL and config.absRefPrefix.
The recommended way to use those is to not set config.baseURL (would result in a <base> tag in the HTML <head>), and set config.absRefPrefix to the subpath where TYPO3 is, relative to the document root. If TYPO3 lies directly in the document root, set it to /.
Second:
In the database, there are "Domain Records". They are usually located on the root page of a site. Change those to the new domain.
Third (with realurl only):
Check the realurl configuration file, usually located in typo3conf/realurl_conf.php. Depending on your setup, the old domain name is used there and needs to be changed.