正在配置htaccess目录索引文件


configuring htaccess directory index file

场景:我创建了这个htacces文件来重定向子域。到目前为止,它是有效的。

<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www'. [NC]
RewriteCond %{HTTP_HOST} ^(.*)'.example'.net$ [NC]
RewriteRule ^(.*) http://example.net/%1/$1 [P,NC,QSA]
</IfModule>

问题:

它强制服务器请求一个不存在的任意index.php。我有index.html,所以我得到了:

Error 404: /xyz/index.php was not found on this server

我尝试添加:

DirectoryIndex index.html index.php [L]

但只有第一个论点被接受,第二个论点被忽略(为什么?)。AFAIK应该接受其中的任何一个,只要其中任何一个存在。

试试这个:我复制了这个,工作正常。

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    public/    [L]
    RewriteRule    (.*) public/$1    [L]
</IfModule>

您应该将"public"更改为文件夹。