如何创建以用户名作为子域名子域? [英] How to create a subdomain with username as subdomain name?

查看:299
本文介绍了如何创建以用户名作为子域名子域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚才提到的其他相关问题,但他们并不清楚我的。请给我解释一下:我怎样才能使子域在PHP

I have referred other related question but they are not clear to me. Please explain me: How can I make subdomain in PHP?

例如:

http://www.domainname.com/page.php?usname=sundar

我要改变连结此

I want change the link to this

http://sundar.domainname.com

这是有可能在PHP?还是有其他的方法来做到这一点?

Is this possible in PHP? Or any other way to do it?

推荐答案

您可以创建一个虚拟的子域,然后你可以用htaccess的重定向。

You may create a virtual sub domains and then you can redirect it with .htaccess.

您还可以建立

实录这个样子

* .exmple.com一个127.0.0.1或者你的IP

在您的DNS。

然后添加像这样在您的的.htaccess

Then add something like this in your .htaccess

重写规则^([AA-ZZ])$ home.php?用户名= $ 1

RewriteRule ^([aA-zZ])$ home.php?username=$1

的RewriteCond%{HTTP_HOST} ^(^ )。mywebsite.com
  重写规则(
的)home.php?用户名=%1

RewriteCond %{HTTP_HOST} ^(^.).mywebsite.com
RewriteRule (.
) home.php?username=%1

这应该有助于

这篇关于如何创建以用户名作为子域名子域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆