【问题标题】:Index.html not accessed when opening website打开网站时未访问 index.html
【发布时间】:2022-02-09 19:01:09
【问题描述】:

我有一个网站,norway-yv.epizy.com。我使用 InfinityFree 托管(我只是想使用该网站进行练习和作为一个有趣的爱好项目)。他们使用 filemanager.ai 来管理我的文件。我有一个庞大的文件和文件夹系统(见下文),我不必上传每个文件和每个文件夹,而是将所有内容都放在网站文件夹中。这样,每次我在网站的本地副本中更改某些内容时,我都不需要上传所有内容。我希望norway-yv.epizy.com 重定向到norway-yv.epizy.com/website/home.html,并通过index.html 文件完成此操作。但是,它只给出错误 404。

我的文件

.htaccess

DirectoryIndex index.php index.html index.htm index2.html

ErrorDocument 403 https://infinityfree.net/errors/403/
ErrorDocument 404 https://infinityfree.net/errors/404/
ErrorDocument 500 https://infinityfree.net/errors/500/

我已在 InfinityFree 控制面板中将http://norway-yv.epizy.com/website/myerrorpages/[errornum].html 配置为错误页面路径

htdocs(文件夹,自动创建)

index.html

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>norway-yv</title>
    </head>
    <body>
        <meta http-equiv="refresh" content="0; url=website/home.html">
    </body>
</html>

website(文件夹,手动创建)

index.html

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>norway-yv</title>
    </head>
    <body>
        <meta http-equiv="refresh" content="0; url=home.html">
    </body>
</html>

home.html

<html lang="en">
    <head>
        <title>norway-yv | home</title>
        <link rel="icon" type="image/png" href="../files/icons/favicon.png">
        <link rel="stylesheet" href="style/normal.css">
    </head>

    <body>
        <header>
            <a href="home.html">
                <img class="logoTop" src="files/icons/favicon.png" alt="Logo" />
            </a>
        </header>
        <h1>This is the website of norway-yv</h1>
        <p>I'm sorry for the horrible look of my website, but it is the best I can do</p>
        <h2>About me</h2>
        <p>I am a hobby developer who likes programming in Python. I am a student in Norwegian upper secondary school, year 1.<br>
            Some of my best projects can be found <a href="projects.html" >here.</a><br>
            Feel free to contact me trough GitHub.</p>
        <h2>Contact</h2>
        <p>
            <a href="https://stackoverflow.com/users/17496608/norway-yv" >StackOverflow</a><br>
            <a href="https://github.com/norway-yv"> GitHub (via GitHub e-mail)</a><br>
        </p>
    </body>
</html>

projects.html

<html lang="en">
    <head>
        <title>norway-yv | projects</title>
        <link rel="icon" type="image/png" href="../files/icons/favicon.png">
        <link rel="stylesheet" href="style/normal.css">
    </head>

    <body>
        <header>
            <a href="home.html">
                <img class="logoTop" src="files/icons/favicon.png" alt="Logo" />
            </a>
        </header>
        <h1>My projects</h1>
        <p>I have made tons more than this, mainly for scientific and mathematic purposes, but these are some of the projects I am most proud of:</p>
        <h2>kode24-calculator</h2>
        <p>An ongoing project, where I try to calculate expected wage for Norwegian developers using many different parametres.<br>
            For more information, see <a href="projects/kode24-calculator.html"> here. </a></p>
        <h2>binary-calculator</h2>
        <p>A project that sort of is finished, but still has a long way to go. Currently, it can calculate the sum of two binary numbers up to 32 bit size and output it.<br>
            For more information, see <a href="projects/binary-calculator.html"> here. </a></p>
    </body>
</html>

我的cmets到底

我的网站中还有很多其他文件夹,还有其他几个文件夹。如果有必要,我可以将它们添加到问题中。但我希望不会。
预览时也会出现同样的问题(使用边缘显示本地版本)。所以我的文件比 InfinityFree 更成问题。

【问题讨论】:

  • 它对我有用。我刚刚测试过。
  • @StephenOstermiller 您是否测试了网站或 HTML(例如,您是否复制到本地并尝试过,或者您是否访问了 www 上的页面?)
  • 我测试了你的网站我没有尝试复制你的代码
  • 当我转到norway-yv.epizy.com 时,我只看到错误 404(我自己的错误 404 页面)
  • 您正在阻止 curl 用户代理,并且需要进行某种 JavaScript 测试才能访问该站点,因此测试起来有点困难。但是我可以通过伪造用户代理并从 Firefox 复制我的 cookie 来测试使用 curl。使用 curl 从命令行进行测试通常是确保您看不到缓存内容的最佳方法。 (否则你必须在每次测试之间清除浏览器缓存。)

标签: html web redirect hosting


【解决方案1】:

可能因为您在&lt;head&gt; 中缺少&lt;base&gt; 标记而无法正常工作。 base 标记定义了基本 URL,从那里重定向相对 URL。

For more

【讨论】:

  • 但是 /website 有效 (norway-yv.epizy.com/website)
  • 在我改变一些东西之前它曾经工作过
  • @norway-yv 你改变了什么?
  • 我把主网站的所有内容都放到了“website”文件夹中,这样我就可以一次上传整个内容了
猜你喜欢
  • 2021-04-02
  • 2022-07-21
  • 2020-09-09
  • 1970-01-01
  • 2018-06-11
  • 2010-10-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多