Reputation: 21
I have 1 IP number 83.87.163.224 and I have 4 multiple domainnames: www.alurelingerie.nl - www.aaamsterdam.info - www.webshopdesigners.nl - www.rtps.eu
Every domeinname must redirect to a sub dir on my Apache server. I tried to work with VirtualHost *:80 but I doesn't work... It doens't redirect to the correct subdir... It did only redirect to the first VirtualHost...
What I want is: www.alurelingerie.nl > must be redirected to http:// 83.87.163.224/alurelingerie/
www.aaamsterdam.info > must be redirected to http:// 83.87.163.224/aaamsterdam/
www.webshopdesigners.nl > must be redirected to http:// 83.87.163.224/webshopdesigners/
www.rtps.eu > must be redirected to http:// 83.87.163.224/rtps/
the rootdir 83.87.163.224 without a subdir > must be redirected to http:// 83.87.163.224/startpagina/
Can someone help me to set this up for my Apache 2.2 server... THX, sorry for my bad English...
Upvotes: 1
Views: 855
Reputation: 32602
Depends on what exactly you mean by the word "redirect". If you're referring to the document root, then virtual hosts are exactly what you need:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName alurelingerie.nl
ServerAlias www.alurelingerie.nl
DocumentRoot /home/websites/alurelingerie.nl
</VirtualHost>
<VirtualHost *:80>
ServerName yourseconddomain.com
ServerAlias www.yourseconddomain.com
DocumentRoot /home/websites/yourseconddomain.com
</VirtualHost>
And so on.. If by "redirect" you mean an HTTP redirect (301, 302) then you should check out mod_rewrite for Apache, it's quite simple - redirect all your domains to one place and place all requests onto a php script, which then determines which domain you were trying to access and issues a Location: /new-location header.
I'm quite sure this could be done without PHP too, but can't think of anything straight away, maybe RewriteCond and RewriteRule with [R=301,L].
Upvotes: 2