Click to See Complete Forum and Search --> : .htaccess subdomain simulation
Iceline
01-25-2007, 07:40 AM
I wasn't quite sure in which forum to put this, so I put it in 'other'. I've searched the internet for solutions to this and there have been sites explaining it, but never in such an understandable way that I was able to realise it.
Is it possible to use a .htaccess file to simulate subdomains? Let's say I have www.domain.com with no subdomains registered but when somebody types test.domain.com the person will see the content of the directory domain.com/test?
If this is possible could you show me the file(s) I should need to use and where I should place it/them?
KingSpork
01-25-2007, 01:53 PM
Well, you can't really do that without some DNS changes too. For example, if you have both example.com and www.example.com pointing to 192.168.1.100, you'll also have to add another "A" record to point foo.example.com to 192.168.1.100 too. How to make this change will vary depending on who manages your DNS and how, but it has nothing to do with Apache.
Assuming you have the DNS thing nailed down, you still might run into a snag though. When Apache receives a request for foo.example.com, it needs to know which website to display. This is done by setting up a Virtual Host (http://httpd.apache.org/docs/2.0/vhosts/name-based.html). The problem though is that you can't do this from a .htaccess file, you'll need to get at http.conf. And unless you have root on the server, you're probably SOL. :(
Iceline
01-26-2007, 08:50 AM
Hm, that's a pitty. I'll have root access though, that wouldn't be a problem. Thanks anyway!
Maybe someone can tell me of an "easy" way to (either through php or htaccess or whatever) give people a subdomain on registering on a site.
Justin
01-30-2007, 01:41 PM
if the problem has to do with you dont want to have all their folders in the root dir of your server, you can use a mod rewrite to make it so when the go to domain.com/justin it would go to /users/justin or something. As for a subdomain system, i can't help ya out, sorry.