Silverstripe& .htaccess - 如何访问特定文件夹并查看目录索引?

时间:2016-01-30 21:35:05

标签: .htaccess silverstripe

当我点击URI /client-files时,我希望能够访问目录索引视图 - 我正在使用Silverstripe,它带有自己的.htaccess开箱即用,我最后提供的

例如domain.com/client-files

我想要实现的示例图像,只是使用不同的文件夹名称...

enter image description here

我尝试了以下内容:

我试过添加 - (这给了我一个500错误):

<Directory "/client-files">
   Options +Indexes
</Directory>

并添加此内容:

RewriteCond %{REQUEST_FILENAME} !-d - 这让我&#34;禁止 - 您无权访问此服务器上的/ client-files /。&#34;

我的 .htaccess (默认)

### SILVERSTRIPE START ###
# Deny access to templates (but allow from localhost)
<Files *.ss>
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
</Files>

# Deny access to IIS configuration
<Files web.config>
    Order deny,allow
    Deny from all
</Files>

# Deny access to YAML configuration files which might include sensitive information
<Files *.yml>
    Order allow,deny
    Deny from all
</Files>

# Route errors to static pages automatically generated by SilverStripe
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html

<IfModule mod_rewrite.c>

    # Turn off index.php handling requests to the homepage fixes issue in apache >=2.4
    <IfModule mod_dir.c>
        DirectoryIndex disabled
    </IfModule>

    SetEnv HTTP_MOD_REWRITE On
    RewriteEngine On
    RewriteBase '/'


    # Deny access to potentially sensitive files and folders
    RewriteRule ^vendor(/|$) - [F,L,NC]
    RewriteRule silverstripe-cache(/|$) - [F,L,NC]
    RewriteRule composer\.(json|lock) - [F,L,NC]

    # Process through SilverStripe if no file with the requested name exists.
    # Pass through the original path as a query parameter, and retain the existing parameters.
    RewriteCond %{REQUEST_URI} ^(.*)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* framework/main.php?url=%1 [QSA]
</IfModule>

### SILVERSTRIPE END ###

1 个答案:

答案 0 :(得分:1)

我最终通过使用@munomono所说的但稍微不同来开始工作。

我最终在/client-files目录中拥有自己的.htaccess文件并将其放入其中:

<强>的.htaccess

RewriteCond %{REQUEST_FILENAME} !-d
Options +Indexes