1

I try to redirect all http query on my website like "http://www.example.com/abcd" (that generate 404 error) to "http://www.example.com/error.php?e=abcd" (to keep the abcd request in a database)

I tried to find a way with .htaccess file, but nothing work fine :(

I tried something like this :

ErrorDocument 404 http://www.example.com/error.php?e=$1

I know I have to do some RewriteCond and RewriteRule stuffs, but I don't know how to use is properly

Thanks

1 Answer 1

1

You should remove http://... to avoid full redirection i.e.:

ErrorDocument 403 /error.php?e=403
ErrorDocument 404 /error.php?e=404

Now you can get original 404 causing URI using:

$_SERVER["REQUEST_URI"]=/abcd

while $_GET['e'] will give you code 404,403 etc in case you want to have some logic based on this.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.