2016-04-12 70 views
1

当用户访问domain.com/test/它应该显示domain.com/test/folder/index.php默认情况下为.htaccess - 在子目录中显示文件夹的内容

index.html    <-- current homepage 
    /test/    <-- .htaccess file 
    /folder/ 
     index.php 

目前我使用:

DirectoryIndex folder/index.php

但有没有其他办法?我试图重写规则,但它不会工作:

RewriteRule ^(.*) /folder/index.php [NC,L,QSA]

+0

'重写规则^ $文件夹/ index.php' – jeremy

+0

@Jeremy我试过这个,但是我得到了403 Forbidden错误。 – forloop

回答

2

您可以使用此规则/test/.htaccess:(。*)

DirectorySlash Off 
Options +FollowSymLinks 
RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^[^/]*$ folder/index.php [L] 
+0

我已经试过这个,但是我得到了403禁止的错误 – forloop

+0

是的,它加载得很好 – forloop

+1

不知道,因为我的答案中没有403导致规则。在你的.htaccess的顶部尝试'Options + FollowSymLinks + Indexes',并确保'文件夹'没有任何.htaccess – anubhava

相关问题