new .htaccess file - added new domain name to virtual hosting

Hello - I added a new domain to a virtual linux web host (Brinkster) and need to create an .htaccess file to redirect to it. I just wanted to make sure I have the proper code. Specifically, for my first domain do I put "public_html/" as the folder name or do I just leave that off?
Here's what I have:

#Turns the rewrite engine on.
RewriteEngine on

#Fix missing trailing slash character on folders.
RewriteRule ^([^.?]+[^.?/])$ $1/ [R,L]

#www.domain.com and domain.com will map to the folder {root}/folder1/
RewriteCond %{HTTP:Host} ^(?:www\.)?mynormaldomainname\.info$
RewriteCond %{REQUEST_URI} !^/public_html]/
RewriteRule ^(.*) folder1/$1 [NC,L,NS]

#www.otherdomain.com and otherdomain.com will map to the folder {root}/folder2/
RewriteCond %{HTTP:Host} ^(?:www\.)?mynewdomain\.com$
RewriteCond %{REQUEST_URI} !^/newdomainfolder/
RewriteRule ^(.*) folder2/$1 [NC,L,NS]

Open in new window


thanks in advance!
Trevor LocalAsked:
Who is Participating?
 
PapertripConnect With a Mentor Commented:
That is not what you want to do, for 2 main reasons.

First off, if domain1 is in public_html, and domain2 is in public_html/folder2, then http://domain1/folder2 will have all of domain2 content in it but accessed via domain1, which could have unforeseen consequences and is obviously not want you want anyways (right?).

Secondly it's best practice to keep things tidy and consistent.  Having subdirectories is nice and clean and keeps everything separate, easy to manage, and scalable.
0
 
InsoftserviceConnect With a Mentor Commented:
hi,

u want to redirect to new domain from old one
#Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.olddomain.com$[OR]
RewriteCond %{HTTP_HOST} ^olddomain.com$
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
it will redirect when u enter ur old site
i hope i have understood ur question properly
0
 
Trevor LocalAuthor Commented:
Hi - I guess I don't want to redirect - they are two separate domains and contents.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
InsoftserviceCommented:
please elaborate little more
0
 
PapertripCommented:
Your example is a bit confusing in regards to your question.  Are you just trying to point each domain to a specific folder on disk?  

What are the significance of these directories as far as these domains are concerned?
/public_html/
/newdomainfolder/

Again I'm not totally clear on what you are trying to do, but all it looks like you need is a change to the DocumentRoot in the vhost conf to point to folder1 and folder2?  Then just create the 2 subdirectories listed above underneath that?
0
 
Trevor LocalAuthor Commented:
Ok - the new domain has it's own content, but web host is sharing an IP, so I just need to redirect new domain to the new folder, and old domain to the current folder. Does that make sense? thanks!
0
 
PapertripCommented:
All you need is to change the
DocumentRoot 

Open in new window

in the conf file for your vhosts to point to folder1 and folder2.  If you can't edit it directly, ask your hosting company to.

The whole thing behind vhosts is that they can share the same IP with other vhosts.  ie: they are virtual hosts.
0
 
Trevor LocalAuthor Commented:
I was doing .htaccess because they sent this link when I asked their support:

Brinkster FAQ
0
 
PapertripCommented:
OK so no editing the conf files through Brinkster it seems.

Just use the example they give in the FAQ.


#Turns the rewrite engine on.
RewriteEngine on

#Fix missing trailing slash character on folders.
RewriteRule ^([^.?]+[^.?/])$ $1/ [R,L]

#www.domain.com and domain.com will map to the folder {root}/folder1/
RewriteCond %{HTTP:Host} ^(?:www\.)?domain\.com$
RewriteCond %{REQUEST_URI} !^/folder1/
RewriteRule ^(.*) folder1/$1 [NC,L,NS]

#www.otherdomain.com and otherdomain.com will map to the folder {root}/folder2/
RewriteCond %{HTTP:Host} ^(?:www\.)?otherdomain\.com$
RewriteCond %{REQUEST_URI} !^/folder2/
RewriteRule ^(.*) folder2/$1 [NC,L,NS]

Open in new window

0
 
PapertripCommented:
create folder1 and folder2 under public_html which is your DocumentRoot for both vhosts.
0
 
Trevor LocalAuthor Commented:
So they already created the folder2. There's the current contents of my first domain inside public_html. So do I need to move the current contents into a folder1?
0
 
PapertripCommented:
Yes.
0
 
Trevor LocalAuthor Commented:
So I drop the .htaccess file into public_html, and that will trigger the redirection to the folders for each domain. Is that right? And I'll need to change some paths for the database connected to domain1.
thanks
0
 
PapertripCommented:
Yes.
0
 
PapertripCommented:
Did this work for you?
0
 
Trevor LocalAuthor Commented:
I'll be testing tonight or tomorrow. I did contact their support and I don't need to move the contents of the domain1 to a new folder but can keep it in public_html.
0
 
Trevor LocalAuthor Commented:
Ah - great points. OK I'll need to figure out the database connection then, for new path of domain1.
0
 
PapertripCommented:
what and where is this database?
0
 
Trevor LocalAuthor Commented:
It's a MySql database for "slideshowpro director". It's housed on a separate VM with the host.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.