1
特定のフォルダ名(およびサブコンテンツ)を.htaccess経由で直接アクセスできるようにする必要があります。起動するには.htaccess経由で特定のフォルダ名への直接アクセスのみを許可する
、私の現在の.htaccess
がある:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
私のファイル構造は、例えば、次のとおりです。
modules/
core/
_test/
publics/
file.txt
other/
_whatever/
publics/
more.txt
publics/
sub/
file.txt
other.txt
.htaccess
私はpublics
フォルダ内にあるファイルとフォルダによる場合を除いて、何もアクセスできませんでした。
- モジュール/コア/国民/ [DIR]
- モジュール/コア/国民/ file.txtを
- モジュール/その他/ _whatever /国民/ [この例では、私は問題なく、アクセスすることができますDIR]
- モジュール/その他/ _whatever /国民/ more.txt
- モジュール/その他/国民/ [DIR]
- モジュール/その他/国民/サブ/ [DIR]
- モジュール/その他/国民/sub/file.txt
- modules/other/publics/other.txt
ファイルやフォルダにアクセスできませんでした。
私は正規表現が必要だと思いますが、これをmod_rewriteでどのように使用して私が望むように動作させることができるのか分かりません。
いくつかの提案はありますか?
回答: http://stackoverflow.com/questions/6379355/htaccess-prevent-access-to-files-and-ディレクトリーブラウズを防止する –