logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

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.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Emulate ErrorDocument using rewrite/rewritecond/redirect etc
Author
capachoty



Joined: 22 Jun 2015
Posts: 4

PostPosted: Tue 23 Jun '15 17:02    Post subject: Emulate ErrorDocument using rewrite/rewritecond/redirect etc Reply with quote

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: 7294
Location: Germany, Next to Hamburg

PostPosted: Fri 26 Jun '15 17:06    Post subject: Reply with quote

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

PostPosted: Mon 29 Jun '15 16:03    Post subject: Reply with quote

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: 7294
Location: Germany, Next to Hamburg

PostPosted: Mon 29 Jun '15 16:32    Post subject: Reply with quote

Only apache could be also ssi since it is a more or less apache thing...
Back to top


Reply to topic   Topic: Emulate ErrorDocument using rewrite/rewritecond/redirect etc View previous topic :: View next topic
Post new topic   Forum Index -> Apache