正規表現が一致しない場合にリダイレクトするにはどうすればよいですか
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^test/(admin)/([A-Z]{2}[0-9]{3})/(xml|json)$ http://localhost/username/index.php?type=$1&id=$2&format=$3 [L]
RewriteRule ^test/(home|member)/([0-9]+)/(xml|json)$ http://localhost/username/index.php?type=$1&id=$2&format=$3 [L]
RewriteRule ^test/.*$ http://localhost/username/error.php [L]
[AZ]{2}[0-9]{3} が一致しない場合、コード ID が無効な入力、RewriteRule ^test/.*$ localhost/username/error.php を示す error.php ページにリダイレクトします。 [L] これは間違った URL パスのエラーになります。
例:
ユーザーが localhost/username/test/admin/TA123/xml と入力した場合、これは有効です。ユーザーが localhost/username/admin/123/xmlll と入力した場合、これは error.php にリダイレクトされ、コードは 500 入力エラーとなります
ユーザーが localhost/username/test/guest と入力すると、error.php にリダイレクトされ、コードは 501 間違った URL と表示されます
ユーザーが localhost/username/test/home/TA123/xml と入力すると、502 入力エラーのコードで error.php にリダイレクトされます