eurusd Posted May 2, 2009 Share Posted May 2, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/156597-how-to-rewrite-domains-to-folders-by-apache-mod_rewrite/ Share on other sites More sharing options...
trq Posted May 3, 2009 Share Posted May 3, 2009 You want to look into configuring virtual hosts not mod_rewrite. Quote Link to comment https://forums.phpfreaks.com/topic/156597-how-to-rewrite-domains-to-folders-by-apache-mod_rewrite/#findComment-824721 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.