Solved

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

Posted on 2011-09-05
19
288 Views
Last Modified: 2012-05-12
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!
0
Comment
Question by:Trevor Local
  • 9
  • 8
  • 2
19 Comments
 
LVL 15

Assisted Solution

by:Insoftservice
Insoftservice earned 100 total points
ID: 36485633
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
 

Author Comment

by:Trevor Local
ID: 36485676
Hi - I guess I don't want to redirect - they are two separate domains and contents.
0
 
LVL 15

Expert Comment

by:Insoftservice
ID: 36485696
please elaborate little more
0
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 
LVL 21

Expert Comment

by:Papertrip
ID: 36485713
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
 

Author Comment

by:Trevor Local
ID: 36485720
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
 
LVL 21

Expert Comment

by:Papertrip
ID: 36485745
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
 

Author Comment

by:Trevor Local
ID: 36485756
I was doing .htaccess because they sent this link when I asked their support:

Brinkster FAQ
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36485807
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
 
LVL 21

Expert Comment

by:Papertrip
ID: 36485821
create folder1 and folder2 under public_html which is your DocumentRoot for both vhosts.
0
 

Author Comment

by:Trevor Local
ID: 36485850
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
 
LVL 21

Expert Comment

by:Papertrip
ID: 36485876
Yes.
0
 

Author Comment

by:Trevor Local
ID: 36485901
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
 
LVL 21

Expert Comment

by:Papertrip
ID: 36485909
Yes.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36493181
Did this work for you?
0
 

Author Comment

by:Trevor Local
ID: 36493484
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
 
LVL 21

Accepted Solution

by:
Papertrip earned 400 total points
ID: 36493652
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
 

Author Comment

by:Trevor Local
ID: 36493678
Ah - great points. OK I'll need to figure out the database connection then, for new path of domain1.
0
 
LVL 21

Expert Comment

by:Papertrip
ID: 36493708
what and where is this database?
0
 

Author Comment

by:Trevor Local
ID: 36493943
It's a MySql database for "slideshowpro director". It's housed on a separate VM with the host.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question