我的主要 public_html 目录具有以下 .htaccess 规则:
Options +FollowSymLinks
IndexIgnore */*
<IfModule mod_rewrite.c>
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
</IfModule>
问题是,然后我有一个名为 source 的子目录,我希望该目录只列出其中的文件(因为没有索引文件)。问题是上述父目录的 htaccess 规则导致目录索引中没有显示源中的文件(它只列出一个空白索引)。
我该如何解决这个问题?
谢谢
请您参考如下方法:
用这个改变你的 .htaccess:
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# if request is not for the /sub-dir/
RewriteCond %{REQUEST_URI} !^/sub-dir/ [NC]
# otherwise forward it to index.php
RewriteRule . index.php
</IfModule>