[英]Is it possible to have a directory listed and hide specific files based on an excluder, i.e HTTP_Host?
Is it possible to have a directory listed and hide specific files based on an excluder, ie HTTP_Host? 是否可以列出目录并基于排除器(即HTTP_Host)隐藏特定文件?
Request for cloud -> from example.com -> Hide all files beginning with xamplee_
Request for cloud -> from xamplee.com -> Hide all files beginning with example_
I tried the following with no success: 我尝试了以下操作,但均未成功:
IndexIgnore xxx
Options -MultiViews
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^xamplee_ xxx [NC,L]
#RewriteCond %{HTTP_HOST} ^www\.xamplee\.com$ [NC]
IndexIgnore êxample_ xxx [NC,L]
I'm not even sure if it is possible at all. 我什至不确定是否有可能。 A different approach would also be welcome.
也欢迎采用其他方法。
OK, based on the exchange in the comments to the question here some means to get you started (hopefully): 好的,根据对问题的评论中的交流,有一些方法可以帮助您入门(希望如此):
The apache http server comes with a bundle of modules. apache http服务器附带了一组模块。 One of those is
mod_dir
which provides features to generate directory listings. 其中之一是
mod_dir
,它提供了生成目录列表的功能。
It offers a standard listing but also allows more flexible usage. 它提供了标准列表,但也允许更灵活的使用。 The "DirectoryIndex" directive allows to declare any object as usable index document for a directory.
“ DirectoryIndex”指令允许将任何对象声明为目录的可用索引文档。 With this you can configure any type of handler generating such an issue.
使用此功能,您可以配置产生此类问题的任何类型的处理程序。 Typical examples would be static html documents or a dynamic
index.php
document, so a php script generating an html based index of the directory at hand. 典型示例是静态html文档或动态
index.php
文档,因此php脚本会生成当前目录的基于html的索引。 Of course any other scripting language can be chosen just as well. 当然,也可以选择任何其他脚本语言。 Its documentation helps with the details: http://httpd.apache.org/docs/2.2/mod/mod_dir.html
其文档有助于详细信息: http : //httpd.apache.org/docs/2.2/mod/mod_dir.html
The the approach here would be to pick a suitable scripting language which is available inside your environment (or make it available) and point the DirectoryIndex directive to a script coded in that language. 这里的方法是选择一种在环境中可用(或使其可用)的合适的脚本语言,并将DirectoryIndex指令指向以该语言编码的脚本。
Another approach would be to create a rewriting rule to relay all requests to directories to a script. 另一种方法是创建重写规则,以将对目录的所有请求中继到脚本。 Comes out more or less the same as long as the script knows what directory it should create the index for.
只要脚本知道应该为其创建索引的目录,它的输出就差不多一样。
That way whenever a request to a directory is coming in that script well be executed and expected to provide the correct html index document for this directory. 这样,只要对该脚本有目录请求,就可以很好地执行该脚本,并期望为该目录提供正确的html索引文档。 Inside such a script you are free to do and output whatever you like.
在这样的脚本中,您可以自由执行并输出所需的任何内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.