Php .htaccess-在子目录中显示文件夹的内容

Php .htaccess-在子目录中显示文件夹的内容,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,当用户访问domain.com/test/时,默认情况下应显示domain.com/test/folder/index.php index.html <-- current homepage /test/ <-- .htaccess file /folder/ index.php index.html您可以在/test/.htaccess中使用此规则: DirectorySlash Off Option

当用户访问domain.com/test/时,默认情况下应显示domain.com/test/folder/index.php

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

index.html您可以在
/test/.htaccess
中使用此规则:

DirectorySlash Off
Options +FollowSymLinks
RewriteEngine On

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

RewriteRule^(.*)$folder/index.php
@Jeremy我尝试了这个,但是我得到了403禁止的错误。不确定,因为我的答案中没有403导致错误的规则。请在.htaccess上尝试“选项+FollowSymLinks+索引”,并确保
文件夹中没有任何.htaccessCorrect!我添加了:
Options+FollowSymLinks
,效果很好。我可以问一下,是否可以保留url而不重定向它?是的,它不会更改url,并且没有
R
标志。让我修改一下答案。