简体   繁体   English

页面未读取URL中没有index.php的查询字符串

[英]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. 当我的服务器升级为使用PHP7时,就会开始发生此问题,因此我怀疑这与它有关。

My website's URLs build the page content based on the query string. 我的网站的URL根据查询字符串构建页面内容。 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"): 另一方面,使用以下URL格式可以正常工作(请注意添加了“ 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. 换句话说,我可以获取prop查询字符串值,而不会出现URL中“ index.php”的问题。 I don't want to use index.php in the URL, I'd like the URLs to remain clean. 我不想在URL中使用index.php,我希望URL保持干净。 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. 这基本上是一个单页面的信息应用程序,它通过该查询字符串值更改内容,因此在域的根部不需要index.php。

Any thoughts as to how I would fix this? 关于如何解决此问题有任何想法吗? Does this have something to do with updating to PHP7 on the server? 这与服务器上的PHP7更新有关吗?

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. 基本上,我意识到问题是我的根目录中有一个index.html文件,并且默认情况下,当未指定索引文件时,服务器会选择该文件。 So naturally there was no PHP present, so it gave the impression that the query string value wasn't being read correctly. 因此自然不存在PHP,因此给人的印象是查询字符串值未正确读取。 After renaming the index.html file, everything works as expected. 重命名index.html文件后,一切正常。

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. 我想知道以前服务器上的设置是否默认设置为使用index.php文件而不是index.html文件。

I'd delete this entire post but I suppose someone else might have the same problem so I'll leave it. 我将删除整个帖子,但我想其他人可能也会遇到同样的问题,所以我将其保留。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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