Apache重定向目录到index.php

时间:2012-08-30 11:14:35

标签: apache .htaccess redirect indexing

我正在尝试将一个简单的文件夹重定向到/folder/index.php。

我的网址如下:site.com/folder,我想要site.com/folder/index.php。 通过网络我只发现相反的方式,但我想看看我的index.php,以便我以后可以使用像site.com/folder/index.php#344这样的链接

我的.htaccess位于/ folder /中,如下所示:

Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^/(.+)$ index.php
</IfModule>

当然它不起作用。 也许是apache无视我的文件?也许还有其他人.htaccess正在干涉?我不知道,因为我是apache的新手......

感谢您的帮助

1 个答案:

答案 0 :(得分:2)

你可以跳过这个mod_rewrite东西并使用mod_dir:

DirectoryIndex index.php

/folder的htaccess文件中,转到http://site.com/folder,您将获得index.php的内容。