htAccess 重定向空 URI 而不是目录列表



如果我只是做Options -Indexes

localhost/subdir/会给我 500 个错误。 但我想将其重定向到 https://github.com/miranda-zhang/cloud-computing-schema

类似的东西

RewriteRule ^$ https://github.com/miranda-zhang/cloud-computing-schema [R=308,L]

目前,这在我的本地服务器上不起作用。

我必须做

RewriteRule ^home$ https://github.com/miranda-zhang/cloud-computing-schema [R=308,L]

并使用网址localhost/subdir/home

此外,Options -Indexes似乎使以下内容停止工作。

ErrorDocument 406 https://miranda-zhang.github.io/cloud-computing-schema/v1.0/406.html
RewriteRule ^.*$ https://miranda-zhang.github.io/cloud-computing-schema/v1.0/406.html [R=406,L]

完整的原始 .htaccess 文件

我还尝试了一些方法在用Apache检测空REQUEST_URI的问题mod_rewrite 以下内容似乎不起作用,或者我可能缺少其他配置。

RewriteCond %{HTTP_HOST} ^localhost/coocon

RewriteCond %{REQUEST_URI}  "^/$" 

似乎还有其他问题,现在是403错误。

禁止 您无权访问此服务器上的/cocoon/。

Cannot serve directory /var/www/html/cocoon/: No matching
DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive

这可能有效:

Options -Indexes
ErrorDocument 403 https://github.com/miranda-zhang/cloud-computing-schema

最新更新