How do I create subdomain like http://user.mywebsite.example? Do I have to access .htaccess somehow? Is it actually simply possible to create it via pure PHP code or I need to use some external script-server side language?
To those who answered: Well, then, should I ask my hosting if they provide some sort of DNS access?
You’re looking to create a custom A record.
I’m pretty sure that you can use wildcards when specifying A records which would let you do something like this:
127.0.0.1would be the IP address of your webserver. The method of actually adding the record will depend on your host.Then you need to configure your web-server to serve all subdomains.
server_name .mywebsite.exampleServerAlias *.mywebsite.exampleRegarding .htaccess, you don’t really need any rewrite rules. The
HTTP_HOSTheader is available in PHP as well, so you can get it already, likeIf you don’t have access to DNS/web-server config, doing it like
http://mywebsite.example/userwould be a lot easier to set up if it’s an option.