Answer the question
In order to leave comments, you need to log in
How to send array by get method via .htaccess redirect?
You need to send an array of parameters like /index.php?array[1]=1&array[2]=2&array[3]=3 with a redirect.
Something like this:
RewriteRule ^page/?$ index.php?array=$1 [L,QSA]
But the regular expression needs to be correct to pass the parameters. And what is the best way to do it?
Answer the question
In order to leave comments, you need to log in
You can do this index.php?array[1]=1&array[2]=2&array[3]=3 , without rewrite in htaccess , then in the $_GET array, by the array key, you will have an array " 1, 2, 3 ".
I don't quite understand why you need rewrites.
Usually, they are used to organize CNC .
Let's say:
In this case, everything after site.ru/ will be redirected to index.php as a GET request. In the $_GET array, this string will be located by the route key.
That is, in order to make an array out of it, you will have to parse this line ( Actually, this is what routing does in the MVC pattern ).
Roughly speaking, you can do this:
$route = $_GET['route'];
$array = preg_split('/\//', $route);
# Activates URL rewriting
RewriteEngine on
# Allow file access
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite rules
RewriteRule ^(.+)$ index.php?route=$1 [L,QSA]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question