I want so that when im in http://localhost/example/category it allows me to have a subdomain that is dynamic like user1.localhost/example/category, user2.localhost/example/category, user3.localhost/example/category etc…
I got it working with the index from localhost but i want it to work when its in the category webpage and only in that webpage I would appreciate if someone could help me underneath is what i tried to do
httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "C:/wamp64/www"
ServerName localhost
ServerAlias *.localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
<Directory "C:/wamp64/www">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
hosts
127.0.0.1 localhost
127.0.0.1 *.localhost
::1 localhost
3
Answers
You can check whether you are on an alias domain and if so, whether it’s the category page:
(untested)
Wildcards are not supported in the hosts file. You may try manually adding multiple entries in the hosts file in order to test whether you have your webserver configured correctly, for example:
Once you are happy that your webserver is configured correctly, your best route to getting wildcard domains working would probably be a local DNS resolver. If you’re on Ubuntu, maybe you can achieve this with resolvconf…
In regards to only wanting it to work on the category webpage, that comes down to the program you are writing. You could probably do some blocking in .htaccess itself, however you are already specifically going to have to handle multiple domains within your web application, so I would suggest you program these restrictions in there as well.