如何更改默认的索引页中的Apache? [英] How do I change the default index page in Apache?

查看:235
本文介绍了如何更改默认的索引页中的Apache?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改默认的网页显示,当我浏览我的网站。我现在有一个报告程序运行,并输出一个名为index.html的文件。我不能改变它所称的文件。因此,我的目标网页必须被调用别的东西。现在,当我浏览我的网站,它需要我申报页面。

I would like to change the default web page that shows up when I browse my site. I currently have a reporting program running, and it outputs a file called index.html. I cannot change what it calls the file. Therefore, my landing page must be called something else. Right now, when I browse my site it takes me to the reporting page.

这是我所看到的,无论你怎么称呼它的index.html将拉动,最多为默认。我想改变这种状况,以landing.html上。我该怎么做呢?

From what I see, whatever you call index.html it will pull that up as your default. I want to change that to landing.html. How do I do this?

我的文件夹(折叠@家)。该报告程序是HFM.net。 HFM能够输出我目前统计的折叠一个html文件。它的名字html文件的索引。我不想说是我的默认主页。我想一个菜单式的降落在那里我可以选择,如果我想看到我的统计,或别的东西。该网站是通过/ home /泰勒/文件/ HFM /网站(landing.html上和HFM的index.html的在这里)。 Apache2的是它的默认目录。

I am a folder (Folding @ Home). The reporting program is HFM.net. HFM can output an html file with my current folding statistics. It names the html file index. I do not want that to be my default home page. I would like a menu-like landing where I can choose if I want to see my stats, or something else. The website is at /home/tyler/Documents/hfm/website (landing.html and hfm's index.html are here). Apache2 is in its default directory.

我也运行Ubuntu 13.04。

I'm also running Ubuntu 13.04.

推荐答案

我推荐使用的.htaccess ...很容易做到的。

I recommend using .htaccess ... very easy to do.

DirectoryIndex home.php

或者任何网页的名称,你想拥有它。

Or whatever page name you want to have for it.

修改:基本htaccess的教​​程

EDIT: basic htaccess tutorial.

1)创建的.htaccess 文件

在您的网站的根目录下,创建一个的.htaccess 文件。

In the root directory of your site, create an .htaccess file.


  • 无扩展名

  • 。在前面,以确保它是一个隐藏的文件

输入上面在那里就行了。有可能会很多很多其他的事情,你会添加到这个(AddTypes对于网络字体/媒体文件,缓存头,gzip的声明COM pression ...我可以永远继续下去),但是这一条线的声明新家的页面。

Enter the line above in there. There will likely be many, many other things you will add to this (AddTypes for webfonts / media files, caching for headers, gzip declaration for compression ... I could go on forever), but that one line declares your new "home" page.

2)设置服务器允许的的.htaccess 文件读取(可能只需要在你的本地主机,如果你的主机servce默认为允许它为大多数人)

2) Set server to allow reading of .htaccess files (may only be needed on your localhost, if your hosting servce defaults to allow it as most do)

假设你有机会,去你的服务器上启用了站点位置。我运行Debian服务器上进行开发,并且默认站点设置为的/ etc / apache2的/网站的可用/默认为Debian / Ubuntu Linux系统。不知道你运行哪些服务器,只是搜索网​​站可用,进入默认的文件。在那里你会看到目录中的条目。修改它看起来是这样的:

Assuming you have access, go to your server's enabled site location. I run a Debian server for development, and the default site setup is at /etc/apache2/sites-available/default for Debian / Ubuntu. Not sure what server you run, but just search for "sites-available" and go into the "default" document. In there you will see an entry for Directory. Modify it to look like this:

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

然后重新启动Apache服务器。同样,不知道你的服务器,但在Debian命令/ Ubuntu是:

Then restart your apache server. Again, not sure about your server, but the command on Debian / Ubuntu is:

sudo service apache2 restart

从技术上只需要重装,但我重启只是因为我感到完全刷新这样更安全。

Technically you only need to reload, but I restart just because I feel safer with a full refresh like that.

一旦做到这一点,您的网站应该从你的.htaccess文件中读取,你应该有一个新的默认主页!一个侧面说明,如果你有一个运行的网站(如管理部分或某事)一个子目录,你想有一个不同的主页该目录,你可以放下另一个。在该子网站的根htaccess的文件,它会覆盖在父的声明。

Once that is done, your site should be reading from your .htaccess file, and you should have a new default home page! A side note, if you have a sub-directory that runs a site (like an admin section or something) and you want to have a different "home page" for that directory, you can just plop another .htaccess file in that sub-site's root and it will overwrite the declaration in the parent.

这篇关于如何更改默认的索引页中的Apache?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆