Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Emulate ErrorDocument using rewrite/rewritecond/redirect etc |
|
Author |
|
capachoty
Joined: 22 Jun 2015 Posts: 4
|
Posted: Tue 23 Jun '15 17:02 Post subject: Emulate ErrorDocument using rewrite/rewritecond/redirect etc |
|
|
OS - 2.6.18-274.7.1.el5
Apache - 2.2.29
Is there anyway to emulate the functionality of the ErrorDocument using rewrite rules, redirects, rewrite conds or other methods.
I'm trying to create a 404 page that can use dynamic variables (not allowed in ErrorDocument), that serves a custom 404 page and also logs a 404 in the HTTP status code in the logs.
I can achieve one or the other but not both as the ErrorDocument does.
Thanks |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Fri 26 Jun '15 17:06 Post subject: |
|
|
Sure you can run all 404 through your handler, but then you have to send the 404 header.
Code: |
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ your404handler.php/$1
|
|
|
Back to top |
|
capachoty
Joined: 22 Jun 2015 Posts: 4
|
Posted: Mon 29 Jun '15 16:03 Post subject: |
|
|
Good advice but I was trying to accomplish this with only apache, php is not allowed in our production environment and our previous cgi was not secure and cgis are no longer allowed to be deployed.
I ended up writing a custom module "Error_Dynamic" in order to accomplish this.
Thank you for the input though, much appreciated. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Mon 29 Jun '15 16:32 Post subject: |
|
|
Only apache could be also ssi since it is a more or less apache thing... |
|
Back to top |
|
|
|
|
|
|