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

查看:368
本文介绍了如何阻止子目录继承父进程的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).

如何解决这个?

谢谢

推荐答案

用这个改变你的.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天全站免登陆