2

私が持っている.htaccessファイルは、「エラー」と呼ばれるサブフォルダで404.htmlドキュメントを見つけることができません。特に行は次のとおりです。

ErrorDocument 404 /error/404.html

ただし、404.htmlを.htaccessと同じディレクトリに配置し、行を次のように変更すると、次のようになります。

ErrorDocument 404 /404.html- - できます!

それが役立つ場合は、 XAMPP for Windowsを使用しています。httpd.confファイルでは、関連するディレクティブが次のように設定されています(冗長性があることに気付きました)。

<Directory />
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

<Directory "C:/xampp/htdocs">
    Options Indexes FollowSymLinks Includes ExecCGI MultiViews
    AllowOverride All
    Require all granted
</Directory>

また、私のDocumentRootは「C:/ xampp / htdocs」に設定されており、「エラー」ディレクトリにアクセスするためにさまざまなパスを試しましたが、機能しません。

ErrorDocument 404 /error/404.html
ErrorDocument 404 /flchi/error/404.html
ErrorDocument 404 /sites/flchi/error/404.html
ErrorDocument 404 /htdocs/sites/flchi/error/404.html

ああ、そしてそれが価値があることの最後の1つは、仮想ホストを使用していることです。関連するビットは次のとおりです。

<VirtualHost *>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
    ServerAlias localhost
    <Directory "C:/xampp/htdocs">
        Options Indexes FollowSymLinks Includes ExecCGI
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost flchi.local>
    DocumentRoot "C:/xampp/htdocs/sites/flchi"
    ServerName flchi.local
    ServerAlias flchi.local
    <Directory "C:/xampp/htdocs/sites/flchi">
        Options Indexes FollowSymLinks Includes ExecCGI
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
4

1 に答える 1

4

これは、名前の競合が原因で発生します。デフォルトのApache構成では、の仮想パスがすでに定義されており/error、すべての仮想ホストにグローバルに影響します。それは設定ファイルで行われますxampp/apache/conf/extra/httpd-multilang-errordoc.conf。場所、したがって、サブディレクトリ/errorをシャドウします。/error

  Alias /error/ "C:/xampp/apache/error/"

'error'サブディレクトリの名前を別の名前(たとえば、)に変更すると機能するはずですerror2

   ErrorDocument 404 /error2/404.html
于 2013-01-21T01:22:14.807 に答える