来自子文件夹的html帖子 - 帖子网址包含网址中的顶级网站

时间:2016-03-14 04:08:43

标签: html html-form html-form-post html-formhandler

我有一个网站:

#include<stdio.h>
#include<string.h>

#define Row 2
#define col 20

int wordCount = 0;
int groupCount = 0;
char wordList[Row][col];
char group[Row][col];

void sortword (char *word);                 
void anagramGrouping (char *word, char *copy);   
void resetGroup();                                   

int main (void) {

    int i;
    char word[col] = "";

    resetGroup();

    for (i = 0; i < Row; i++)
    {
        scanf ("%s", word);
        sortword (word);
        wordCount++;
    }

    return 0; /* main is a function of type 'int' and returns a value */
}

void resetGroup()
{
    int i;

    for (i = 0; i < Row; i++)
        *group[i] = 0;
}

void sortword (char *word)
{
    int i = 0; 
    char temp;
    char copy[col] = "";

    strcpy (copy, word);

    while (word[i]) {
        int j = i + 1;
        while (word[j]) {
            if(word[j] < word[i]) {
                temp = word[i];
                word[i] = word[j];
                word[j] = temp;
            }
            j++;
        }
        i++;
    }
    anagramGrouping (word,copy);
}

void anagramGrouping (char *word, char *copy)
{
    int n;

    if (!wordCount)
        strcpy (group[0],copy);

    for (n = 0; n < Row; n++) {
        if (strcmp (group[n], word) == 0)
            strcpy(group[n],copy);
        else {
            groupCount++;
            strcpy (group [groupCount],copy);
        }
    }
}

有一个子文件夹(子网站):

example.com/index.html

different_index.html包含一个表单:

example.com/subsite/different_index.html

但是,单击此表单上的提交输入按钮时,页面将尝试重定向到:

<FORM action="different_index.html?action=edit">

我已尝试将表单操作设为所需的确切网址:

example.com/subsite/subsite/different_index.html

但我仍然得到:

<FORM action="example.com/subsite/different_index.html?action=edit"> <!-- target self -->

子网站在网址中重复。

如何正确定位此表单的任何想法?

1 个答案:

答案 0 :(得分:0)

你有表格的事实实际上是无关紧要的。您真正要问的是引用资源,规则非常简单:

  1. 如果您需要的资源是同一网站的一部分(这里不讨论文件夹结构,谈论域名),您应该使用相对路径,其中:

    一个。如果资源与当前加载的文档位于同一文件夹中,则只需 fileName.ext

    湾如果您需要的文件位于加载文档所在的当前文件夹的子文件夹中,则需要 folderName / fileName.ext

    ℃。如果您需要的文件比当前文档的文件夹高一个目录,则 ../ fileName.ext 即可使用。如果您需要上升多个级别(即 ../../ fileName.ext ),可以重复../。

    d。 / fileNameext /folderName/fileName.ext 表示无论当前文档位于何处,都应从网站的根目录开始找到指定的文件或文件夹。

  2. 如果您需要的资源位于其他域中,则您使用绝对路径http://something.something/file.ext)。

    一个。不要对本地资源使用绝对路径!这可能有效但会导致必须再次解析域名,从而导致加载时间更长。

  3. 警告:不同的服务器具有不同的配置和要求,可能会影响这些参考规则是否有效。例如,GoDaddy虚拟主机提供了一个&#34; httpDocs&#34;文件夹在网站的根目录。您不必使用它,但这是他们的服务器希望放置网站内容的地方。不遵循这些规则会导致相对路径无效。此外,许多服务器托管在具有区分大小写的文件系统的操作系统上,因此请始终在实际使用的相同大小写中引用文件和文件夹。再说一次,不这样做可能会在你本地工作,而你开发(因为你还没有将文件移动到远程服务器),但不要让你认为这种情况不会发生。无所谓。