我有一个域www.domain.com
,我有用户使用用户名在其上创建配置文件。我已经为他们创建了一个机制,让他们使用 htaccess 和 index.php 文件中的一些代码www.domain.com/username
访问他们的公共个人资料。
我的.htaccess文件看起来像这样:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L,QSA]
另一个功能是用户可以为其配置文件选择设计(第一或第二设计)。因此,我将所选设计存储在数据库中,并将www.domain.com/username
重定向到www.domain.com/1/
或www.domain.com/2/
,并在该URL上加载用户配置文件。PHP 中的逻辑是
//Load profile of user
$requestURI = $_SERVER['REQUEST_URI'];
$parameterArray = explode('/', $requestURI);
$username = $parameterArray[1];
if($username != "")
{
//Get chosen design from database and store it in a variable
$chosenDesign = *Selected design value*;
header("Location: $chosenDesign/");
}
else
{
//Username not found, hence redirect to error page
header("Location: 404.html");
}
我的问题是,我如何以始终www.domain.com/username
URL并在后台加载设计(逻辑上)并显示它的方式进行重定向。
无法在可见链接中隐藏信息。您可以使用这样的链接:
www.domain.com/username-1
重定向至 -> www.domain.com/page.php?user=username&design=1
对于这种东西,我使用饼干...