I have a domain www.domain.com
and I have users who create profiles on it with a username. I have created a mechanism for them to access their public profile as www.domain.com/username
using htaccess and some code in index.php file.
My .htaccess file looks like this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L,QSA]
An additional feature is that users can select a design (1st or 2nd design) for their profile. So I store the chosen design in database and redirect www.domain.com/username
to www.domain.com/1/
or www.domain.com/2/
and load the users profile on that URL. The logic for that in PHP is
//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");
}
My problem is, how can I redirect in such a way that the URL is always www.domain.com/username
and it loads the design in the background (logically) and displays it.