Search code examples
php.htaccessnotice

PHP - Why do i get Undefined index on $_GET variable? (possible .htaccess clash)


I'm trying to make a data filter with php and to do so, I want to use a form with 'get' method. Not the problem is, that I get this notice, when I'm trying to refer to any of the $_GET['var']'s.

echo $_GET['kraj'];

Notice: Undefined index: kraj in C:\wamp\www\inc\pages\filtr.php on line 23

And here is the URL code:

alt text

What I think may be the problem is .htaccess file, that rewrites the URL's to pretty ones.

Here is an example of my .htaccess:

RewriteEngine on
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?detail1=$1&detail2=$2&detail3=$3 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?detail1=$1&detail2=$2 [L]
RewriteRule ^([^/\.]+)/?$ index.php?detail1=$1 [L]

Is it possible to refer to $_GET[''] after the '?' simbol with those rules? If not, how can I fix it, so it can work.

Thanks, Mike


Solution

  • Add QSA to the flags to append to the query string instead of replacing it.