简体   繁体   English

如何使网站正常工作,以使“index.html”不会出现在网站名称之后的主页链接上?

[英]How do I make a website work so that "index.html" does not appear on my home page's link after the website name?

After uploading to a web hosting service, my home page has a name as follows: example.com/index.html Is there any way that I can change the index.html in the link to "home" or something else?上传到 web 托管服务后,我的主页名称如下: example.com/index.html有什么方法可以将index.html中的链接更改为“home”或其他内容?EZ I am using Bluehost if that helps.如果有帮助,我正在使用 Bluehost。

index.html is designed to never show up in URLs to users. index.html旨在永远不会出现在用户的 URL 中。 index.html is the document powers requests for the directory. index.html是该目录的权限请求文件。 If index.html is showing up in your URLs, that usually means that you are linking to the home page incorrectly.如果index.html出现在您的 URL 中,这通常意味着您错误地链接到主页。

Modify your links:修改您的链接:

  • <a href=http://example.com/index.html><a href=http://example.com/> <a href=http://example.com/index.html><a href=http://example.com/>
  • <a href=/index.html><a href=/> <a href=/index.html><a href=/>
  • <a href=index.html><a href=./> <a href=index.html><a href=./>

Of those, I would suggest using <a href=/> to link to our home page.其中,我建议使用<a href=/>链接到我们的主页。 That is a site-relative link to your home page.这是指向您主页的站点相关链接。 It will work on any page on your site, regardless of how deep in directories it is.它适用于您网站上的任何页面,无论目录有多深。 Unlike absolute links, it is easy to use the same code on a live server and on a staging server.与绝对链接不同,在实时服务器和登台服务器上使用相同的代码很容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM