Is there any to to capture query string and append it to error document (404). Something like:
Requested page:
http://www.example.com/sdsdsd
Redirect to:
http://www.example.com/404.php?pg-name=sdsdsd
Is there any to to capture query string and append it to error document (404). Something like:
Requested page:
http://www.example.com/sdsdsd
Redirect to:
http://www.example.com/404.php?pg-name=sdsdsd
Instead of using ErrorDocument in the htaccess configuration, you could force a real redirect to the error.php like this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /error.php?pg-name=%{REQUEST_FILENAME} [L]
Source: How to get `$_POST` query when 404 redirected through .htaccess?
In the error.php page you can then check, if the pg-name parameter is given to the error.php:
echo '<pre>';
print_r($_GET);
echo '</pre>';
If you call you page like this: http://domain1.com/asdasdasd (assuming the link is not found), the output from the error.php will look like this:
Array
(
[pg-name] => /path_to/public_html/asdasdasd
)
Then you can get to the requested string "asdasdasd".