3
如何限制訪問我的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>
'css'文件通常需要公開訪問。你是什麼意思*「由應用程序正確使用」*。如果您的意思是在您的客戶端應用程序/代碼中使用它,那麼它需要公開訪問。如果你的意思是你想在你的服務器端代碼中使用它,那麼我建議你從公用文件夾中刪除這個文件。 – Wilt
我不想在瀏覽器上顯示結構,或者是不可能的? –
檢查[這裏](https://www.thesitewizard.com/apache/prevent-directory-listing-htaccess.shtml)或[這裏](http://stackoverflow.com/questions/2530372/how-do-i -disable-目錄瀏覽) – Wilt