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
[mod_rewrite] Routing different domains to different directorys
Old 06-08-2010, 01:51 PM [mod_rewrite] Routing different domains to different directorys
Junior Talker

Posts: 1
Trades: 0
Hello!

Ive registered here in the hope that anyone can help me. I actually made Google smoke, but didnt find a result that matched my problem. Please excuse my maybe not-so-good english, its not my mother tounge

Description:
Ive got two official domains that point to one webserver that has got an official IP out there. Behind the official IP is a single Apache webserver thats running on a Debian server OS.
For example:
www.company1.com -> 11.22.33.44
www.company2.com -> 11.22.33.44

In the web root are two folders and a .htaccess file:
.
..
.htaccess
company1/
company2/

So when i enter the www.company1.com Domain, i want the browser to be redirected to the folder company1/. And company2/ for the second domain of course.
Now i have already tried to make a php workaround by rewriting the header after reading the referrer that the browser sent. That did work with some browsers, but not with all.

So my second idea was to use mod_rewrite, which seems to be a bit more difficult^^

After some Googling, my .htaccess file looks like that:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^company1\.com$
RewriteRule (.*) http://www.company1.com/$1 [R=301,L]
RewriteRule ^$ company1 [L]

RewriteCond %{HTTP_HOST} ^company2\.com$

RewriteRule (.*) http://www.company2.com/$1 [R=301,L]
RewriteRule ^$ company2 [L]


Actually this works for company1, it redirects the user to www.company1.com/company1 after entering www.company1.com.

The problem is that www.company2.com is redirected to the same directory, i.e. www.company2.com/company1.

I hope anyone is fit enough to help me with this .htaccess file,

Much thanks in advance,
Charly
draumsyn is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-09-2010, 09:32 AM Re: [mod_rewrite] Routing different domains to different directorys
Experienced Talker

Posts: 41
Name: Conrad
Trades: 0
What you need to do is look up some information on the "VirtualHost" directive in Apache. You need to edit your httpd.conf file to add in a seperate VirtualHost for each domain name you want to host (and don't forget to add domains with "www." at the start and without!).

Best of luck
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
MakeFreeCashMan is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to [mod_rewrite] Routing different domains to different directorys
 

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.10152 seconds with 12 queries