如何阻止子目录继承父级的 htaccess 规则 [英] How to stop sub directory inheriting parent's htaccess rules

查看:40
本文介绍了如何阻止子目录继承父级的 htaccess 规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的主要 public_html 目录具有以下 .htaccess 规则:

My main public_html directory has the following .htaccess rules:

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 规则导致目录索引中没有显示源中的文件(它只是列出了一个空白索引).

The problem is, I then have a subdirectory called source, and I want that directory to just list the files within it (because there is no index file). The problem is the above parent directory's htaccess rules are causing no files in source to be shown in the directory index (it just lists a blank index).

我该如何解决这个问题?

How can I solve this?

谢谢

推荐答案

用这个改变你的 .htaccess:

Change your .htaccess with this:

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>

这篇关于如何阻止子目录继承父级的 htaccess 规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆