php - .htaccess 和会话
问题描述
链接来自我网站上的外部网站,其中包含以下行:
https://mywebsite.com/transfer.html?id=34。
PHP 脚本将 id 放入 $_SESSION: 此处为 34。
我的问题:我希望,一旦 id (34) 将 id 放入 $_SESSION 中,链接的显示将被修改如下 - 隐藏变量 id 以仅显示网站:
https ://mywebsite.com/
我在.htaccess中试过这个:
RewriteRule ^/?transfer\.html https://mywebsite.com [L]
RewriteCond %{QUERY_STRING} ^id=[0-9]{1,2}$
RewriteRule /$ /? [R=301,L]
但令人担忧的是我得到:
https ://mywebsite.com/?id=34
谢谢你的帮助
解决方案
我遵循 SaidbakR 的建议并直接在我的函数文件中执行此操作 - 实际上,不需要 .htaccess:
header ('Status: 301 Moved Permanently', false, 301);
header ('Location: /');
exit ();
重定向效果很好。
谢谢你的运动。