[英]htaccess for subdomain to the main domain
we are trying to create .htaccess redirect for our website, here is what we would like to do: 我们正在尝试为我们的网站创建.htaccess重定向,这是我们想要做的:
Our domain: http://freewebsites.com 我们的域名: http : //freewebsites.com
we would like to redirect all users coming to http://freewebsites.com/username to http://username.freewebsites.com/ 我们希望将所有访问http://freewebsites.com/username的用户重定向到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 最好的方法是将PHP与GET变量一起使用
Make a page called index.php and place this code in it 创建一个名为index.php的页面并将此代码放入其中
<?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 如果您将用户发送到URL,则使用此
http://freewebsites.com/index.php?Username=TestUser
Will be send to 将发送到
http://TestUser.freewebsites.com
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.