Silverstripe & .htaccess - 如何访问特定文件夹并查看目录索引?
Silverstripe & .htaccess - How to access a specific folder and view the directory index?
我希望能够在我点击 URI 时访问目录索引视图 /client-files
- 我正在使用 Silverstripe,它自带 .htaccess
开箱即用,我在结束。
例如domain.com/client-files
我想要实现的示例图像,只是文件夹名称不同...
我试过以下方法:
我尝试添加-(这给了我一个 500 错误):
<Directory "/client-files">
Options +Indexes
</Directory>
并添加:
RewriteCond %{REQUEST_FILENAME} !-d
- 这给了我 "Forbidden - You don't have permission to access /client-files/ on this server."
我的.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 ###
我最终通过使用@munomono 所说但略有不同的方式让它工作。
我最终在 /client-files
目录中有了自己的 .htaccess 文件并将其放入其中:
.htaccess
RewriteCond %{REQUEST_FILENAME} !-d
Options +Indexes
我希望能够在我点击 URI 时访问目录索引视图 /client-files
- 我正在使用 Silverstripe,它自带 .htaccess
开箱即用,我在结束。
例如domain.com/client-files
我想要实现的示例图像,只是文件夹名称不同...
我试过以下方法:
我尝试添加-(这给了我一个 500 错误):
<Directory "/client-files">
Options +Indexes
</Directory>
并添加:
RewriteCond %{REQUEST_FILENAME} !-d
- 这给了我 "Forbidden - You don't have permission to access /client-files/ on this server."
我的.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 ###
我最终通过使用@munomono 所说但略有不同的方式让它工作。
我最终在 /client-files
目录中有了自己的 .htaccess 文件并将其放入其中:
.htaccess
RewriteCond %{REQUEST_FILENAME} !-d
Options +Indexes