Link to home
Start Free TrialLog in
Avatar of Trevor Local
Trevor Local

asked on

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!
SOLUTION
Avatar of Insoftservice inso
Insoftservice inso
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Trevor Local
Trevor Local

ASKER

Hi - I guess I don't want to redirect - they are two separate domains and contents.
please elaborate little more
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?
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!
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.
I was doing .htaccess because they sent this link when I asked their support:

Brinkster FAQ
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

create folder1 and folder2 under public_html which is your DocumentRoot for both vhosts.
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?
Yes.
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
Yes.
Did this work for you?
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.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ah - great points. OK I'll need to figure out the database connection then, for new path of domain1.
what and where is this database?
It's a MySql database for "slideshowpro director". It's housed on a separate VM with the host.