1

On my site, one of my pages when loaded never contains a GET value.

The beginning of the script is:

print_r($_GET);
print_r($_SERVER);

For $_SERVER I get:

REQUEST_URI => /dir/sub_dir/script_name/?s=30&v=20
QUERY_STRING => 

and for $_GET I just have: Array ( )

This doesn't seem to be a problem for any other page.

What could be causing this?

10
  • Can't you access by index/key the values? Commented May 28, 2014 at 21:39
  • 2
    I have a few quick questions: do you have any .htaccess URL rewriting taking place? Is the script being included from another script? What happens if you access the script with as /dir/sub_dir/index.php?s=30&v=20? Commented May 28, 2014 at 21:41
  • 1
    My first thought would be that you are using url rewrite to route pages to scripts and are missing the QSA flag in the RewriteRule. QSA="query string append". Meaning that any additional get string passed is also added to the url rewrite. Commented May 28, 2014 at 21:44
  • Are you using a framework? This happens a lot with MVC frameworks, including CakePHP. Commented May 28, 2014 at 21:51
  • @GigaWatt, I edited my question, I left out the part of the script_name which is included in the query. It is not an index page, but the URL is re-written via .htaccess to remove .php and add /. Sorry for not mentioning that. I use the same rewriting rules for other scripts without problems. Commented May 28, 2014 at 22:16

1 Answer 1

1

I had my .htaccess files locally deleted and I forgot that in one of the sub directories, I did have a .htaccess with some deny/allow rules and that for was breaking the GET but everything else was loading. Deleting the .htaccess (or fixing it to allow properly) made the GET values start working again.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.