I'm using shared hosting on which I host a website and have got some "parked domains" (they show the same content as the master domain). I'd now like to catch those domains and show different content, effectively having separate websites for them.

I can change the DNS records and the .htaccess file, but I either end up creating endless loops or getting a 500 server error.

If a user visits domain1.com they are shown content from the www directory. I'd like this to stay this way.

I'd like it so that if users visit domain2.com they're shown content from the domain2 directory. The highest level at which I can create folders is /home/myaccount/www/ - this means that in the example above the content for domain2 would be stored in /home/myaccount/www/domain2

Can I achieve what I want using only DNS settings and url rewriting, or do I need to upgrade my hosting?

Any help would be greatly appreciated!

Thanks.

link|improve this question
you need to write yourself a little bit of code that loads a page depending on the domain used to connect :-) – Ash Palmer Oct 29 '10 at 12:35
feedback

1 Answer

What you need is to set up Apache Virtual Hosts (or similar if the webserver isn't apache) ( http://httpd.apache.org/docs/2.0/en/vhosts/name-based.html ). I'm not sure if this works with .htaccess, i rather think no - than you should contact your webhoster. With just one webspace-acc you can't solve the problem with DNS. With url rewriting that could be a solution: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html (scroll down to "Virtual User Hosts")

link|improve this answer
Thanks for your help. Looking into it further I think a "Virtual User Host" might be the best idea. RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.[^.]+\.host\.com$ RewriteRule ^(.+) %{HTTP_HOST}$1 [C] RewriteRule ^www\.([^.]+)\.host\.com(.*) /home/$1$2 However, I've tried this code and it doesn't seem to work. I have other rewrite rules that are working though. How do I ensure that the request from the user contains a Host:HTTP header? Is there something I can add to my html page headers? – user58639 Oct 29 '10 at 16:33
You have to adapt it, here is an example: zeitfeed.com/2010/10/29/… The most browsers should support this method. I'm not sure how you can play safe, maybe google can help you more. – zaub3r3r Oct 29 '10 at 22:29
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.