[英]Hide directory listing when accessing public folders in the browser
如何限制訪問我的zend框架2公用文件夾,例如css
文件夾? 我想隱藏當我通過http
訪問文件夾時顯示的目錄列表。 但我希望應用程序可以正確使用這些文件。
當我訪問我的域上的css
文件夾時,將顯示此目錄列表:
虛擬主機配置:
<VirtualHost *:80>
ServerName server1.jobsoft.co
ServerAlias server1.jobsoft.co
DocumentRoot /var/www/html/engsvc_dev/public
ErrorLog /var/log/httpd/engsvc_dev.error.log
CustomLog /var/log/httpd/engsvc_dev.common.log common
<Directory /var/www/html/engsvc_dev/public>
DirectoryIndex index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
我的.htaccess
文件:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?server1.jobsoft.co$
RewriteCond %{REQUEST_URI} !^/engsvc_dev/public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /public/$1
RewriteCond %{HTTP_HOST} ^(www.)?server1.jobsoft.co$
RewriteRule ^(/)?$ /public/index.php [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
我編輯了您的問題並添加了術語“目錄列表”,因為這是通常調用屏幕上顯示的文件列表的方式。 起初我在閱讀你的問題后並不知道你想要什么。 但是在你的評論之后我得到了它。
通常,您可以通過向Apache服務器的.htaccess
文件添加其他規則來阻止目錄列表。
您可以在stackoverflow上搜索主題,找到有關如何執行此操作的大量帖子,例如此處或此處或更多內容 。
魔術被關閉:
Options -Indexes
然后轉過來
Options +Indexes
在此apache文檔中,您可以閱讀選項指令一章中的以下內容:
索引如果請求映射到目錄的URL並且該目錄中沒有
DirectoryIndex
(例如,index.html
),則mod_autoindex
將返回該目錄的格式化列表。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.