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