0

我有以下 .htaccess 文件:

DirectoryIndex index.html

Options +FollowSymLinks
RewriteEngine On

AddEncoding gzip .gz
AddEncoding gzip .gzip
<FilesMatch "\.(js.gz|js.gzip)$">
  ForceType text/javascript
</FilesMatch>
<FilesMatch "\.(css.gz|css.gzip)$">
  ForceType text/css
</FilesMatch>

#RewriteCond %{REQUEST_URI} .*/http-bind
#RewriteRule (.*) /http-bind [L]

RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} !/ow_updates/index\.php
RewriteCond %{REQUEST_URI} !/ow_updates/
RewriteCond %{REQUEST_URI} !/ow_cron/run\.php
RewriteCond %{REQUEST_URI} !/index\.html
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.xml|\.feed|robots\.txt|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php

我希望 .htaccess 中的所有其他内容都像以前一样工作:重定向所有请求,除了那些用!to指定的请求index.php。但是,我需要index.html在第一次加载网站时加载,然后它们会继续加载index.php

所以我DirectoryIndex index.html在开头加了一行,然后又加了一行RewriteCond %{REQUEST_URI} !/index\.html,希望用户在输入的时候http://url.com,会被带到index.html文件中,从里面进入到内页,http://url.com/homepage里面的页面都是由index.php.

但是,这不起作用。我使用的软件是Oxwall。该站点只是忽略了第一行并继续加载 index.php 无论如何。我能做些什么来解决这个问题?谢谢。

4

1 回答 1

1

您可以通过会话或 cookie 使用 PHP 轻松处理此问题。您可以让它始终将某人重定向到 index.php,并且在 index.php 中您可以包含 index.html 文件以显示他们是否是第一次访问。如果您将它们重定向到 html 文件,它将不起作用(.htaccess 会妨碍您),但如果您包含该文件,那么它应该可以正常工作。

于 2012-12-18T23:26:44.397 回答