0

私たちは私たちのウェブサイトのために.htaccessリダイレクトを作成しようとしています、これが私たちがしたいことです:

私たちのドメイン: http: //freewebsites.com

http://freewebsites.com/usernameにアクセスするすべてのユーザーをhttp://username.freewebsites.com/にリダイレクトしたいと思います。

これは、Webサイトにアクセスするすべての人を対象としています。したがって、インデックスファイルなどは必要ありません。

4

1 に答える 1

0

このための最良の方法は、GET変数でPHPを使用することです。

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");
}
?>

これを使用して、ユーザーをURLに送信します

http://freewebsites.com/index.php?Username=TestUser

に送信されます

http://TestUser.freewebsites.com
于 2013-06-06T14:33:23.170 に答える