Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用.htaccess重写创建虚拟用户名.domain.com_Php_.htaccess_Subdomain - Fatal编程技术网

Php 如何使用.htaccess重写创建虚拟用户名.domain.com

Php 如何使用.htaccess重写创建虚拟用户名.domain.com,php,.htaccess,subdomain,Php,.htaccess,Subdomain,我知道有很多像我问的问题,但整天在搜索解,我没有找到适合我的,所以我问了这个问题。以下是.htaccess代码,我必须查看用户配置文件: 我现在有这样的个人资料 使用此重写用户配置文件URL是: $1//其中$1是用户名 在这种类型的URL中,我想创建子域用户URL,如: 有人能提出解决办法吗?非常感谢。 <?php $domain = explode( '.' , $_SERVER['HTTP_HOST'] ); $subdomain = $domain[0]; $sql = 'SEL

我知道有很多像我问的问题,但整天在搜索解,我没有找到适合我的,所以我问了这个问题。以下是.htaccess代码,我必须查看用户配置文件: 我现在有这样的个人资料

使用此重写用户配置文件URL是:

$1//其中$1是用户名

在这种类型的URL中,我想创建子域用户URL,如:

有人能提出解决办法吗?非常感谢。


<?php
$domain = explode( '.' , $_SERVER['HTTP_HOST'] );
$subdomain = $domain[0];
$sql = 'SELECT user_id FROM users WHERE username = \''.addslashes($subdomain).'\'';
?>

运行查询。如果找到此用户,则可以在profile.php页面中包含您的URL。

您想将profile.php URL重定向到username.domain.com,对吗?您可以使用htaccess执行此操作,但是,您必须确保您正在创建的子域中有可用的配置文件。