您好我无法通过我的引导程序获取url查询并显示页面。所以我想采取
site.com?page=user-verify&username=name&hash=12345
并获取
site.com/user-verify/name/12345
首先,我通过index.php将所有请求路由到htaccess,如此
Options +FollowSymLinks -MultiViews -Indexes
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /admin/index.php?page=$1&username=$2&hash=$3 [QSA]
然后我的索引查看查询并获取页面
if (isset($_GET['page']))
{
$query = $_GET['page'];
}
elseif (!isset($_GET['page']))
{
header('location:home');
}
switch ($query)
{
case 'home':
drawPage(
'home.php',
'Admin Control Panel',
'This is the homepage description'
);
break;
case 'register':
drawPage(
'register.php',
'Register Page',
'This is the register page description'
);
break;
case 'user-verify':
drawPage(
'user-verify.php',
'Verify User',
'This is the register page description'
);
break;
default:
var_dump($query);
break;
当我添加& username = name时,网址变为用户验证。如果我添加/命名url将成为user-verify / name。
如何在我的页面查询后添加更多查询并使它们与上面的示例非常相似?
答案 0 :(得分:1)
替换此行
RewriteRule ^(.*)$ /admin/index.php?page=$1&username=$2&hash=$3 [QSA]
通过这一行
RewriteRule ^(.*)/(.*)/(.*)$ /admin/index.php?page=$1&username=$2&hash=$3 [QSA]