繁体   English   中英

htaccess网址重写和PHP $ _GET ['id']问题

[英]htaccess url rewrite and PHP $_GET['id'] issue

我想改写我的网址

message.php?id = 372186

讯息/ 372186

这是我的htaccess

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: 
?>

难道我做错了什么? 谢谢。

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

看到那行您说?pg = $ 1?

当您应该使用$ _GET ['pg']时,您正在尝试$ _GET ['id']

暂无
暂无

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

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