apache - How to catch URL user was trying to reach with ErrorDocument in .htaccess -


so have .htaccess file in apache with

errordocument 400 /error.php?e=400 errordocument 401 /error.php?e=401 errordocument 403 /error.php?e=403 errordocument 404 /error.php?e=404 errordocument 500 /error.php?e=500 

i want send along url user trying reach, like

errordocument 400 /error.php?e=400&u=url errordocument 401 /error.php?e=401&u=url errordocument 403 /error.php?e=403&u=url errordocument 404 /error.php?e=404&u=url errordocument 500 /error.php?e=500&u=url 

is possible?

it not possible pass requested uri errordocument directive. alternatives are;

1) use php script error handler , grab requested uri php.

.htaccess:

errordocument 404 /404.php 

404.php:

if (!isset($_get['search'])) {          $q = trim($_server['request_uri'], '/');         header('location: http://' . $_server[http_host] . '/404.php?search=' . $q);         die();  } else {          // search code...  }  ?> 

2) use mod_rewrite.

.htaccess:

options +followsymlinks rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule .* /404.php?search=%{request_uri} [l,r=404] 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -