|
-
Dec 14th, 2009, 03:01 PM
#1
Thread Starter
Frenzied Member
.htaccess, PHP and multiple error documents
Hi guys.
I have an interesting question for anyone that may know the answer or even if it's possible.
I'm working with PHP pages and .htaccess error documents. I'm trying to redirect multiple error documents to the same file, error.php, but can't seem to figure out how to distinguish them in the actual file since the ErrorDocument statement doesn't seem to allow queried outputs.
Does anyone know if there is a way to do this without using fake files with redirects?
Cheers.
-
Dec 14th, 2009, 03:37 PM
#2
Re: .htaccess, PHP and multiple error documents
Not sure if this is what you mean, but you can have your errors all redirect to one location...
Code:
ErrorDocument 404 /path/to/error.php
ErrorDocument 403 /path/to/error.php
#etc.
...and then on error.php, you can use any of the variables in $_SERVER to identify details about the error. For example, make this your error.php page:
Code:
<?php
print_r($_SERVER);
?>
And you can see everything you've got to work with.
-
Dec 14th, 2009, 03:43 PM
#3
Thread Starter
Frenzied Member
Re: .htaccess, PHP and multiple error documents
I've tried that. There is nothing in the $_SERVER variable that gives any information about the error. Any there certainty doesn't seem to be anything there that would help distinguish error types apart.
-
Dec 14th, 2009, 04:05 PM
#4
Re: .htaccess, PHP and multiple error documents
You sure?... I've set this up on my domain here (the URL doesn't exist, so what you're seeing is the error page). The error type appears to be in REDIRECT_STATUS: 404.
What type of information are you looking for specifically?...
-
Dec 14th, 2009, 04:08 PM
#5
Thread Starter
Frenzied Member
Re: .htaccess, PHP and multiple error documents
I just checked that and it didn't show anything to do with 404. Hmm. It could be due to the interaction of the other .htaccess documents though. I'll have to do some research on that.
-
Dec 15th, 2009, 03:10 AM
#6
Re: .htaccess, PHP and multiple error documents
Hi,
This is just a thought but could you use the include ('filename here'); statement the include files in the running of the error.php then have code in error.php checking what error was passed and act appropriately?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Dec 15th, 2009, 03:13 AM
#7
Thread Starter
Frenzied Member
Re: .htaccess, PHP and multiple error documents
I was going to do something like that but the code was more messy than I like. I had to manually redirect each HTTP error code with the ErrorDocument directive to a file with an error value parameter and render the required page.
-
Dec 20th, 2009, 07:18 PM
#8
Re: .htaccess, PHP and multiple error documents
Keep your existing URLS (they are pointing to the same server right?) and add a reqwrite condition to point them to an alternate PHP script.
-
Dec 21st, 2009, 02:43 AM
#9
Thread Starter
Frenzied Member
Re: .htaccess, PHP and multiple error documents
That would work. It seems not to be needed any more though since I changed the structure of the pages - now the original rewrites work fine
-
Dec 21st, 2009, 04:23 AM
#10
Re: .htaccess, PHP and multiple error documents
I shall one day prove to you beyond all reasonable doubt that I am awsome.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|