将domain1.com重定向到domain2.com/page

时间:2019-03-29 15:01:38

标签: .htaccess seo url-redirection data-migration

我已经搜索了一段时间,看到了一些类似的问题,但没有找到我想要的东西。

我有两个域,例如 domain1.com domain2.com 。我将内容从 domain1.com 迁移到文件夹 domain2.com/page 。除此之外,所有子弹都将保持完全相同。因此,我将要 domain1.com 重定向到 domain2.com/page ,以及诸如 domain1.com/whatever 之类的任何路径重定向到 domain2.com/page/whatever 等。这是所需的代码还是其他?

RewriteEngine On

# First condition, requested resource is not an existing file in domain1.com (this condition can be removed if needed)
RewriteCond %{REQUEST_FILENAME} !-f

# Second condition, requested resource is not an existing directory file in domain1.com (this condition can be removed if needed)
RewriteCond %{REQUEST_FILENAME} !-d

# Third condition, slug must exist
RewriteCond %{REQUEST_URI} !^/?$

# Do the redirection
RewriteRule ^(.*)$ http://domain2.com/$1 [R=301,QSA,L]

1 个答案:

答案 0 :(得分:0)

只需这样做:

void find_name(const char *csv_filename, const char *name){
    FILE *csvFile = fopen(csv_filename, "r");
    char word[1000];

    if (csvFile == NULL)
            exit(EXIT_FAILURE);

    while ( !feof(csvFile) ) {
            fscanf(csvFile, "%s%*[^,]", word);
            if ( strcmp(word, name) == 0 )
                    printf("name found");
    }
    fclose(csvFile);
}

别忘了这些空间。