【发布时间】:2014-12-05 19:33:43
【问题描述】:
我正在尝试从此网址中的变量获取动作值。
真实网址
index.php?action=ok&id=45&name=LG-Optimus
友好的网址
home/ok/1/LG-P88
当重定向这样的页面时,上面的友好网址显示
header('Location: /home/ok/' . $id . '/' . $name);
包含获取变量代码的页面脚本
$ok = isset($_GET['ok']) ? $_GET['ok'] : "";
if($ok=='ok'){
echo "<div class='popup'>";
echo "<strong>{$card-name}</strong> added!";
echo "";
echo "</div>";
}
但我得到'未定义的索引ok'。
.htaccess 文件包含此代码
# Turn Rewrite Engine On
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
# Rewrite for index.php
RewriteRule ^home index.php [NC,L]
# Rewrite for card-name
RewriteRule ^home/([0-9]+)/([0-9a-zA-Z_-]+)$ index.php?action=$1&id=$2&name=$3 [QSA,L]
感谢您的帮助。
【问题讨论】: