Вопрос

You can see what I'm talking about in the screenshot below.

Basically, I have a subdomain (i.e. subdomain.website.com) and all I want on it is a single HTML document to display. The HTML document is titled home.php in the image but it should be home.html, which I'll change later.

When I open subscribe.website.com in my browser, I'm presented with the 2nd image, and have to click on the document link to display it. Is there a way to set it up so that when I go to subscribe.website.com, home.html document loads automatically?

screen shot

Это было полезно?

Решение

What you are trying to achieve can be done in multiple ways:

  • The simplest way would be to rename your file as index.html This is because most web servers are configured by default to server some default document's, of which index.html is one, and so is index.php if you fancy it.
  • Another way is to add your-page-name.ext to that list of default document's. But the way to do this is server dependent. You seem to have a Linux host. In which case, you can use the solution provided by @Ethanh by adding DirectoryIndex home.html to your .htaccess file. If this doesn't work, there is the possibility that your host doesn't allow you to edit .htaccess files. In this case, you will have to contact your web host.
  • If your server was a Windows based machine, you would have had to add the same document name to the default document list of IIS
  • There are more ways, each increasing in complexity, which for the level of this answer, I'll keep out.

Другие советы

Use the following code in your htaccess:

DirectoryIndex home.html

You can change it to whatever you like.

when the file is in html format it will load the website automatically rather than show you the file in a list

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top