エラーコードを指定してインデックスを送信して送信するために、.htaccessファイルを書き込もうとしています。例index.php?error404またはindex.php?error501。.htaccessを使用したエラーのキャッチ
以下のコードを使用してルートディレクトリ内でエラーを指示できます。
ErrorDocument 404 index.php?error=404
ErrorDocument 501 index.php?error=501
例http://www.domain.com/file_does_not_exist.phpとなります。 結果http://www.domain.com/index.php?error=404
問題は、サブディレクトリからindex.phpエラーをキャッチして送信することです。
例http://www.domain.com/directory_does_not_existまたは http://www.domain.com/directory_and/file_does_not_exist.phpです。
結果はhttp://www.domain.com/directory_does_not_exist/index.php?error=404であるため、index.phpのCSSが壊れています。
私は以下のコードを成功させようとしました。 URLを書き換えてindex.phpにリダイレクトしようとしています。
RewriteCond $1 !^err[45][0-9][0-9]$
RewriteRule ^\/.\/\.php$ /index.php?s=$1 [R]
AND
RewriteCond $1 !^err[45][0-9][0-9]$
RewriteRule ^([/]?*)\.php$ /index.php?s=$1 [QSA,L]
ご協力いただければ幸いです。
fast&correct! – undone