如何使自定义301页面正常工作?

I want to make a custom 301 page, not the usual apache one.

I added this to .htaccess

ErrorDocument 301 /301.php

I have made the "design" for this page, but how can I make it read the redirectmatch entries in .htaccess and use them? If that's not possible I could make something like if("$_SERVER[REQUEST_URI]" ==), etc. but it would take a very long time. Is there another way?

Edit: To clarify for anyone who didn't understand, I want to change the html code of the default 301 page, which currently looks like this for me:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="/index.php">here</a>.</p>
</body></html>

I have already made the custom one but I don't know how to make read from .htaccess what to redirect.