Kirby L. Wallace Kirby L. Wallace - 1 year ago 80
HTML Question

html post from subfolder - post url includes top level site in URL

I have a site:

There is a subfolder (subsite):

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:

I've tried making the form action the exact url needed:

<FORM action=""> <!-- target self -->

But I still get:

subsite is duplicated within the URL.

Any ideas how to correctly target this form?

Answer Source

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:

  1. 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.

  2. 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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download