How can the Apache server be configured to redirect users to specific error pages based on error codes in PHP?

To configure the Apache server to redirect users to specific error pages based on error codes in PHP, you can use the ErrorDocument directive in the .htaccess file. This directive allows you to specify custom error pages for different HTTP status codes.

```php
ErrorDocument 404 /errors/404.php
ErrorDocument 500 /errors/500.php
```

In this example, any 404 errors will be redirected to the "404.php" page located in the "errors" directory, and any 500 errors will be redirected to the "500.php" page in the same directory. Make sure to create the custom error pages in the specified locations for this configuration to work properly.