: Can I create dynamic subdomains with .htaccess? I want to create dynamic subdomains using only a .htaccess file. For example: http://site.asd/user.php?name=jon > http://jon.site.asd/ http://site.asd/user.php?name=username
I want to create dynamic subdomains using only a .htaccess file. For example:
site.asd/user.php?name=jon > jon.site.asd/ http://site.asd/user.php?name=username > username.site.asd/
How can I set up my .htaccess to redirect like this?
More posts by @Heady270
1 Comments
Sorted by latest first Latest Oldest Best
You can do this without using .htaccess at all. What you need to do is define a wildcard DNS record directing all queries on the subdomains to your application server. The using whatever language you are developing in you would check the host header (fully qualified domain name) to identify the user being requested. Then as part of your application code if the user exists do what you need to, if the user does not exist return an error saying that the user does not exist.
NB: This is very much how GitHub Pages works.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.