简体   繁体   中英

Page not reading query string without index.php in the URL

this problem started happening when my server got upgraded to use PHP7, so I suspect it has something to do with that.

My website's URLs build the page content based on the query string. For example:

example.com/?prop=one  
example.com/?prop=two  
example.com/?prop=three
etc...

But for some reason, when I do the following:

$prop = $_REQUEST["prop"];

or:

$prop = $_GET["prop"];

It does not recognize the specified query string value.

On the other hand, using the following URL format works fine (note the addition of "index.php"):

example.com/index.php?prop=one  
example.com/index.php?prop=two  
example.com/index.php?prop=three

In other words, I'm able to grab the prop query string value without a problem with the presence of the "index.php" in the URL. I don't want to use index.php in the URL, I'd like the URLs to remain clean. This is basically a single page info-app that changes the content via that query string value, so there should be no need for index.php at the root of the domain.

Any thoughts as to how I would fix this? Does this have something to do with updating to PHP7 on the server?

Well, this is embarrassing.

Basically I realized that the problem was that I had an index.html file at the root, and the server was picking that up by default when the index file wasn't specified. So naturally there was no PHP present, so it gave the impression that the query string value wasn't being read correctly. After renaming the index.html file, everything works as expected.

I'm wondering if the settings on my previous server were set to pick up the index.php file by default instead of index.html.

I'd delete this entire post but I suppose someone else might have the same problem so I'll leave it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM