How to Rewrite Domains to folders, by apache mod_rewrite? I have got many domains like this: Mybestdomain.com Londondomen.co.uk Primedomainame.info Promotion.television.org Blogging.mysite.com News.freedomains.co.uk Tv.news.blogging.net Internet.news.blogging.net …. Etc….. They are all pointing to one ip and to one folder /home/www/allinone/ All these domains take many files from folder /home/www/allinone/oftenusedfiles/ /home/www/allinone/oftenusedfiles2/ /home/www/allinone/oftenusedfiles3/ /home/www/allinone/usedfilesabc/ and from /home/www/allinone $root= _SERVER["DOCUMENT_ROOT"]; by include ( $root.â€/ oftenusedfiles/usedfunction.incâ€); …… etc ……….. How to do this: When I enter domain in my browser lets say http://Mybestdomain.com/ it shows http://Mybestdomain.com/ but goes to /home/www/allinone/ Mybestdomain.com Or when I enter domains in my browser for example: http:// Londondomen.co.uk it shows same URL but fetches data from Londondomen.co.uk Basically like this domain name becomes a folder with according name http://%{HOST_NAME}/ ---------ïƒ /home/www/allinone/%{HOST_NAME}/ http://%{HOST_NAME}/script.php?show=45 ---------ïƒ /home/www/allinone/%{HOST_NAME}/script.php?show=45 http://%{HOST_NAME}/%{REQUEST_URI%{QUERY_STRING} ---------ïƒ /home/www/allinone/%{HOST_NAME}/%{REQUEST_URI}%{QUERY_STRING} http:// Blogging.mysite.com gets data from /home/www/allinone/ Blogging.mysite.com/ http:// Promotion.television.org gets data from /home/www/allinone/ Promotion.television.org/ …. /home/www/allinone/ Londondomen.co.uk/ /home/www/allinone/ News.freedomains.co.uk/ /home/www/allinone/ Internet.news.blogging.net/ Tried all I could nothing works, I really don’t understand reg exp and rewrite RewriteCond %{HTTP_HOST} ^(.+)$ RewriteRule (.+) /%{HTTP_HOST}/ [QSA,L] RewriteRule /%{HTTP_HOST}/%{REQUEST_URI} [QSA,L] Etc… THANK YOU FOR YOUR HELP!
Hey There, I don't know about rewrites, but the proper way to do it is by using Apache's Virtual Hosts. http://httpd.apache.org/docs/2.0/vhosts/examples.html It allows you to re-route domains to folders. - Example; <VirtualHost *:80> Servername yourdomain.com ServerAlias www.yourdomain.com ServerAdmin admin@yourdomain.com DocumentRoot "C:\whatever\htdocs\yourdomain.com" </VirtualHost> Code (markup): Regards, Steve
but how do i get then document root? it would be domain name i want common document root for every domain