Apache没有在地址栏上显示index.html

时间:2013-06-19 00:36:03

标签: apache mod-rewrite

我想在地址栏上显示我的index.html文件。当您转到http://www.example.com/将其重定向到http://www.example.com/index.html并在地址栏上显示index.html。

修改

这是我的.htaccess文件。我试过新的例子,但没有运气。

DirectoryIndex  naslovnica.php
Options -Indexes

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* 404.html [L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /naslovnica\.php
RewriteRule ^naslovnica\.php$ http://example.com/naslovnica.php [R=301,L]

1 个答案:

答案 0 :(得分:0)

您必须查看Apache DocumentRoot目录。看看下面的Apache Docs ......

Apache DocumentRoot

您必须创建index.html并将其放在DocumentRoot目录中。

来自DOCS ......

If your DocumentRoot "/usr/web" then an access to http://my.example.com/index.html refers to /usr/web/index.html

<强>被修改
以下文档说明了隐藏索引。猜猜你也可以用它来取消隐藏索引。

Mod_Rewrite – Hide index.php

以下可能是寻找正确解决方案的开始......

Options +FollowSymLinks
RewriteEngine on
# Redirect client requests for www.example.com/ to "www.example.com/index.html" in main doamin
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html
RewriteRule ^index\.html$ http://www.example.com/index.html [R=301,L]
相关问题