Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website and Server Administration Forum


You are currently viewing our Website and Server Administration Forum as a guest. Please register to participate.
Login



Reply
How to Rewrite Domains to folders, by apache mod_rewrite?
Old 05-02-2009, 08:21 PM How to Rewrite Domains to folders, by apache mod_rewrite?
Junior Talker

Posts: 2
Trades: 0
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
hxxp://Mybestdomain.com/ it shows hxxp://Mybestdomain.com/ but goes to
/home/www/allinone/ Mybestdomain.com
Or when I enter domains in my browser for example:
hxxp:// 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

hxxp://%{HOST_NAME}/ ---------à /home/www/allinone/%{HOST_NAME}/

hxxp://%{HOST_NAME}/script.php?show=45 ---------à /home/www/allinone/%{HOST_NAME}/script.php?show=45

hxxp://%{HOST_NAME}/%{REQUEST_URI%{QUERY_STRING} ---------à /home/www/allinone/%{HOST_NAME}/%{REQUEST_URI}%{QUERY_STRING}


hxxp:// Blogging.mysite.com gets data from /home/www/allinone/ Blogging.mysite.com/
hxxp:// 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!
eurgbp is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-15-2009, 06:50 AM Re: How to Rewrite Domains to folders, by apache mod_rewrite?
Skilled Talker

Posts: 55
Name: Brian
Trades: 0
Hello,

I was doing some research on one of my own posts, and I found something that may help you:

from:
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

For HTTP/1.0 requests there is no solution, but for HTTP/1.1 requests which contain a Host: HTTP header we can use the following ruleset to rewrite http://www.username.host.com/anypath internally to /home/username/anypath:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.[^.]+\.host\.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^www\.([^.]+)\.host\.com(.*) /home/$1$2
bmp99 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to Rewrite Domains to folders, by apache mod_rewrite?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13562 seconds with 12 queries