Solved

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

Posted on 2011-09-05
19
285 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
 
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now