Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
htaccess url重写和PHP$获取[';id';]问题_Php_.htaccess_Url Rewriting - Fatal编程技术网

htaccess url重写和PHP$获取[';id';]问题

htaccess url重写和PHP$获取[';id';]问题,php,.htaccess,url-rewriting,Php,.htaccess,Url Rewriting,我想从中重写我的url message.php?id=372186 到 信息/372186 这是我的访问权限 RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteEngine On RewriteRule ^message/([^/.]+)/?$ /message.php?pg=$1 [L] RewriteCond %{

我想从中重写我的url

message.php?id=372186

信息/372186

这是我的访问权限

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteEngine On
RewriteRule ^message/([^/.]+)/?$ /message.php?pg=$1 [L]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [L]
我可以加载example.com/test/message/372186,但当我尝试获取页面id时,它不会返回任何内容

如果我使用message.php?id=372186,php工作正常

<?php
echo $_GET['id'];
// output for message.php?id=372186 is: 372186
// output for message/372186 is: 
?>


我做错什么了吗?谢谢。

重写规则^message/([^/]+)/?$/message.php?pg=$1[L]

看到你说的那行了吗?pg=1美元


你正在尝试$\u GET['id'],而你应该使用$\u GET['pg']

谢谢你,我很愚蠢。我将其更改为message.php?id=$1,但仍然不起作用。请尝试执行var_dump($_-GET)并查看$_-GET变量包含的内容,以便调试。还可以尝试使用此正则表达式进行测试,它接受所有内容:^message/(.*)/$我不能100%确定它是否起作用,但如果无法使用/不使用尾部斜杠,则可能需要创建第二个规则来尝试这两个规则,var_dump提供了数组(0){},它无法获取任何数据