0

我需要index.html在实际index.php安装在服务器上之前加载单个文件。

我有:

index.html- (介绍页)

index.php- (实际网页索引文件)

.htaccess rewrite rule

听起来很简单,但 .htaccess 会将每个网页查询重定向回我的 index.html 文件。

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.html [QSA,L]
</IfModule>

让它发挥作用的最佳方法是什么?

4

2 回答 2

0

Don't use mod_rewrite, use DirectoryIndex and give priority to index.html

DirectoryIndex index.html index.php

Note: While this should work, I don't recommend it as it creates ambiguity. One of those configuration changes that will haunt you later.

于 2013-07-11T19:48:47.967 回答
0

You can simply use DirectoryIndex directive for that:

DirectoryIndex index.html index.php 

From the documentation:

The DirectoryIndex directive sets the list of resources to look for, when the client requests an index of the directory by specifying a / at the end of the directory name. Local-url is the (%-encoded) URL of a document on the server relative to the requested directory; it is usually the name of a file in the directory. Several URLs may be given, in which case the server will return the first one that it finds. If none of the resources exist and the Indexes option is set, the server will generate its own listing of the directory.

于 2013-07-11T19:49:41.550 回答