如何使用用户名作为子域名创建子域?
I have referred other related question but they are not clear to me. Please explain me: How can I make subdomain in PHP?
我已提到其他相关问题,但我不清楚。请解释一下:如何在PHP中创建子域?
Example :
示例:
http://www.domainname.com/page.php?usname=sundar
I want change the link to this
我想改变这个链接
http://sundar.domainname.com
Is this possible in PHP? Or any other way to do it?
这可能在PHP?或者其他任何方式吗?
3 个解决方案
#1
5
You may create a virtual sub domains and then you can redirect it with .htaccess.
您可以创建虚拟子域,然后可以使用.htaccess重定向它。
You also have to create
你还必须创建
A Record look like this
记录看起来像这样
*.exmple.com A 127.0.0.1 or your IP
* .exmple.com A 127.0.0.1或您的IP
in your DNS.
在您的DNS中。
Then add something like this in your .htaccess
然后在你的.htaccess中添加这样的东西
RewriteRule ^([aA-zZ])$ home.php?username=$1
RewriteRule ^([aA-zZ])$ home.php?username = $ 1
RewriteCond %{HTTP_HOST} ^(^.).mywebsite.com
RewriteRule (.) home.php?username=%1RewriteCond%{HTTP_HOST} ^(^。)。mywebsite.com RewriteRule(。)home.php?username =%1
It should help
它应该有所帮助
更多相关文章
- 一套PHP做app接口的解决方案
- curl获取网页内容出现乱码或为空的解决方案,另附curl_getinfo函数
- PHP实现WebSocket示例
- PHP XAMPP配置PHP环境和Apache80端口被占用解决方案
- PHP基础示例:商品信息管理系统v1.1[转]
- 040-PHP使用闭包函数来进行父实例的变量自增,正确示例
- mysql锁机制之示例讲解
- mysql主从同步报slave_sql_running:no的解决方案
- win7下Django的MySql安装,问题解决方案