Php if(isset($\u GET))参数未按预期工作

Php if(isset($\u GET))参数未按预期工作,php,Php,我有这个网址 http://localhost/example/products.php/full/grains?name_product=rice&refer_url=index-desktop-sidemenu 在实时服务器上 http:www.example.com/products.php/full/grains?name_product=rice&refer_url=index-desktop-sidemenu 我试图检查if中是否有$\u GET[“name\u

我有这个网址

http://localhost/example/products.php/full/grains?name_product=rice&refer_url=index-desktop-sidemenu
在实时服务器上

http:www.example.com/products.php/full/grains?name_product=rice&refer_url=index-desktop-sidemenu
我试图检查if中是否有$\u GET[“name\u product”]存在,但当它存在时,似乎没有在URL中检测到
name\u product

这就是我试过的

<?php
if (!empty($_GET["name_product"])){ 
    echo $new_tag = $_GET["name_product"];
    echo "Found";
} else {
    echo "Not found";
}
?>

将products.php添加到主文件中

full/grains?name_product=rice
您在哪里使用谷物?那么您是否有任何.htaccess文件,如果它存在,那么您可以像这样使用

#RewriteEngine On
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /grains.php?name_product=$1&refer_url=$2 [L,QSA]

让我知道它是否有效,但这将改变url的当前结构…

full/grains?name\u product=rice
您在哪里使用
grains?
那么您是否有任何.htaccess文件,如果它存在,那么您可以使用like

#RewriteEngine On
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /grains.php?name_product=$1&refer_url=$2 [L,QSA]
让我知道它是否工作,但这将改变url的当前结构…

我让它工作了

.htaccess
RewriteRule ^products/(.*)$ ./products.php?name_product=$1&refer_url=$2 [NC,L,QSA]

products.php
if (!empty($_GET["name_product"])){ 
echo $new_tag = $_GET["name_product"];
echo "Found";
} else {
echo "Not found";
}
我成功了

.htaccess
RewriteRule ^products/(.*)$ ./products.php?name_product=$1&refer_url=$2 [NC,L,QSA]

products.php
if (!empty($_GET["name_product"])){ 
echo $new_tag = $_GET["name_product"];
echo "Found";
} else {
echo "Not found";
}


简单测试,添加一个
echo“”。打印($获取,1)。”
您在
.htaccess
中是否有某种
mod_rewrite
规则?“这可能会搞乱“获取参数”佩特赫达:是的,我知道do@Shasha好的,请用
mod_rewrite
规则更新问题。@Petrhejda将更新规则简单测试,添加
echo“”。打印($获取,1)。”
您在
.htaccess
中是否有某种
mod_rewrite
规则?“这可能会搞乱“获取参数”佩特赫达:是的,我知道do@Shasha好的,请用
mod_rewrite
规则更新问题。@Petrhejda会更新规则谢谢你的回答。htaccess之后,我只获得完整信息/grains@Shasha你想说什么?请你描述一下……更新了问题嗨,完成了更新,添加了我的mod rewrite和products.php,而grains是一个重写的get参数。谢谢你的回答,在.htaccess之后,我只获得完整的/grains@Shasha你想说什么?请你多描述一下…更新了问题嗨,完成了更新,添加了我的mod rewrite,还有products.php是页面,而grains是一个重写的get参数。您没有标记我的答案correct@Rstdevelpzz很抱歉,已经做了。谢谢@Shashayou没有标记我的答案correct@Rstdevelpzz很抱歉,已经做完了。谢谢@Shasha