How to create a subdomain with username as subdomain name?

自作多情 提交于 2019-11-29 23:22:22

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

You also have to create

A Record look like this

*.exmple.com A 127.0.0.1 or your IP

in your DNS.

Then add something like this in your .htaccess

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

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

It should help

my way:
you will have to create a wildcard subdomain and point it you your domain.

http://www.easymodrewrite.com/example-subdomains

Then you can parse $_SERVER['HTTP_HOST'] for querying out the user name .

if you are under hosting plane, you can probably create it from the GUI.
Else, you need to via the APACHE panel and configure the DNS.

You could use .htaccess url rewrite to make that.

Just rewrite www.(username).site.com to www.site.com/profile/(username)

the code for that would be something like..

RewriteRule ^(.*).site.nl site.nl/profile/$1

if my memory serves me right

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!