How can I send multiple $_GET["x"] variables using htaccess?

307 Views Asked by At

so far everything good with this but.....

$custom_path= "musical_instruments";
echo '< a href='$custom_path' >custom link< /a>'

I'm able to use the $_GEt["custom_path"] in the page I'm redirected

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ localhost/folder/folder/stuff.php?custom_path=$1

how to send multiple $_GET variables form a custom link so I can use them in the page I'm redirected to?

I did it this but is not quite what I want to know:

$custom_path = "category=$category&item_name=$url&item_id=$id";

php

$custom_path= "musical_instruments";
$item_name= "guitar";
$item_id= 123;

echo '< a href='$custom_path&$item_name&$item_id' >custom link< /a>'

htaccess

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ localhost/folder/folder/stuff.php?custom_path=$1&item_name=$2&item_id=$3

how can I have access to the variables $1, $2 and $3 of a custom link? am I doing something wrong with the way I'm building the custom link?

1

There are 1 best solutions below

0
On BEST ANSWER

Not sure what you really want with this one but this is how you create a valid link use double quotes instead of single qoutes if you want to use variables inside it.

$custom_path= "musical_instruments";
$item_name= "guitar";
$item_id= 123;

echo "< a href='?custom_path=$custom_path&item_name=$item_name&item_id=$item_id'>custom link< /a>";

Havent tested it but this should do the trick

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !stuff\.php$
RewriteRule ^(.*)$ /folder/folder/stuff.php?%{QUERY_STRING} [L]

Beware that this might get you in an endless loop and produce a 500 error