How to pass a query string in error 404 error through .htaccess?

I have an index.php file that processes all requests to the server. I set a 404 error for redirection in .htaccess as follows:

 ErrorDocument 404 /index.php 

If the user requests a file, say, page.php , it will be redirected to index.php correctly.

The problem occurs when users request page.php?page=about, then my index.php is unable to retrieve the query near using $ _ REQUEST ['page'] `.

How can I get the about request via index.php using $_REQUEST['page'] ?

+2
source share
1 answer

$_SERVER['REDIRECT_QUERY_STRING'] may contain your query strings.

Take a picture.

 <?php print_r($_SERVER['REDIRECT_QUERY_STRING']); ?> 
+6
source

Source: https://habr.com/ru/post/914623/


All Articles