$ _GET无法使用.htaccess重写删除php扩展

时间:2018-03-13 09:52:29

标签: php .htaccess get

以下网址:

https://example.com/rewards.php&id=307658063902(无法通过GET获取ID)

OR

https://example.com/rewards&id=307658063902(未找到返回错误)

使用php检索GET变量ID不起作用:

$id = $_GET["id"];

我认为我的.htaccess文件可能存在错误,即:

Options -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [NC,L]

1 个答案:

答案 0 :(得分:0)

你错过了吗?在您的网址中,尝试以下示例并检查:

https://example.com/rewards.php?id=307658063902
$id = $_GET["id"];
echo $id;

示例输出:

307658063902