Apache 如何避免在浏览目录列表时显示斜杠
到目前为止,我的.htaccess文件中有以下配置:Apache 如何避免在浏览目录列表时显示斜杠,apache,.htaccess,Apache,.htaccess,到目前为止,我的.htaccess文件中有以下配置: IndexOptions HTMLTable IndexOptions FoldersFirst IndexOptions IgnoreCase #IndexOptions SuppressRules #IndexOptions SuppressDescription IndexOptions SuppressLastModified IndexOptions SuppressSize IndexOptions SuppressColumnS
IndexOptions HTMLTable
IndexOptions FoldersFirst
IndexOptions IgnoreCase
#IndexOptions SuppressRules
#IndexOptions SuppressDescription
IndexOptions SuppressLastModified
IndexOptions SuppressSize
IndexOptions SuppressColumnSorting
IndexOptions SuppressHTMLPreamble
#IndexOptions ScanHTMLTitles
IndexOptions NameWidth=*
IndexOptions DescriptionWidth=*
HeaderName /header.htm
ReadmeName /footer.htm
IndexIgnore ..
IndexIgnore header.htm
IndexIgnore footer.htm
...
我需要在.htaccess文件中添加一些内容,以便在我的页面中列出文件夹和子文件夹时,不会显示每个尾随斜杠
我的页面没有index.htm文件,只显示所有文件夹和目录,如下所示:
AB/
AC/
BA/
BR/
FL/
FO/
...
在AB/中,您还有许多其他文件夹:
aback/
abacus/
abaft/
abandon/
aberration/
abet/
...
在abacus/中,您还有许多其他文件夹:
translation1/
translation2/
translation3/
...
我希望在浏览目录列表时不要显示斜杠。我在网上搜索了两天,但没有找到答案,或者我找到了,但不知道如何使用它
非常感谢。默认情况下,如果未使用mod dir访问现有目录,则mod dir会向其添加一个尾随斜杠。要禁用目录斜杠,可以在htaccess中使用以下行:
DirectorySlash off
这允许您访问一个目录而不使用斜杠,并告诉mod dir如果请求现有目录,则不要添加斜杠
要从URI中删除尾部斜杠,可以使用以下命令:
DirectorySlash off
RewriteEngine on
RewriteRule ^(.*)/$ /$1 [L,R]
尝试它有很多关于设置.htacces目录视图样式的示例。谢谢你的回答。后面的斜杠一直显示在我的目录列表中,使用第二个选项,服务器将显示一个错误页面。