we are trying to create .htaccess redirect for our website, here is what we would like to do:
Our domain: http://freewebsites.com
we would like to redirect all users coming to http://freewebsites.com/username to http://username.freewebsites.com/
This should be for anyone coming to the website. so, we don't need to have a index file or something.
the best method for this would be to use PHP with a GET Variable
Make a page called index.php and place this code in it
<?php
// check to see if Variable 'Username' is sent to it
if(isset($_GET["Username"])){
// if sent set User var
$user = $_GET["Username"];
//Send user to domain
header("Location: http://$user.freewebsites.com");
}else{
// if not send back to main domain
header("Location: http://freewebsites.com");
}
?>
using this if u send the user to the URL
http://freewebsites.com/index.php?Username=TestUser
Will be send to
http://TestUser.freewebsites.com
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.