domain1.com to domain2.com/folder/subfolder/subfolder/

Using a single web hosting account to host multiple sites

domain1.com to domain2.com/folder/subfolder/subfolder/

Postby coderfriend » Sun Aug 03, 2008 12:11 pm

Hi guys,

I have been at this for 2 days now and I can't seem to get it to work

I want domain1.com to redirect to subdomain.domain2.com/folder/subfolder and then show domain1.com in the address bar

I'm currently using this (hosted on domain1.com):

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain1.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain1.com$
RewriteRule ^(.*)$ http://subdomain.domain2.com/folder/subfolder [R=301,L]

This actually works fine and domain1.com / www.domain1.com link to subdomain.domain2.com/folder/subfolder - but this is also showing up in the address bar

I would just like to have www.domain1.com showing instead of that

any suggestions?

thank you so much!

cp
coderfriend
 
Posts: 1
Joined: Sun Aug 03, 2008 11:48 am

Postby richardk » Sun Aug 03, 2008 2:38 pm

What are the document roots of the two domains? Are they on the same server?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^(.*)$ /folder/subfolder/$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby AngTalunin » Wed Oct 22, 2008 4:17 am

I have a similar problem, but can't figure it out:

I have 1 main domain and several other domains which are aliasses for the main domain.

Let's say domain.com is the main domain. On this site 1 have several subsites:
domain.com/1/domain1/
domain.com/2/domain2/

I have rules to rewrite this to something like:
page.php?id_domain=1 and page.php?id_domain=2

Now I want to add domain1.com and domain2.com and display the same page as on the main domain.

So when I go to
- domain2.com I want to see the same domain as on domain.com/2/domain2/
- domain2.com I want to see the same domain as on domain.com/2/domain2/

This can quite easily be done by a 301 redirect, but I do not want the visitors of domain2.com see that they are visiting a page domain.com.

I looked around and tried a lot of rewrite rules, but can't get it to work. I've alread got to this:

RewriteCond %{HTTP_HOST} www.domain1.com$ [NC]
RewriteCond %{REQUEST_URI} !^/1/domain1/.*$
RewriteRule ^(.*)$ {HTTP_HOST}1/domain1/$1 [NC, L]

Idea is:
cond1: capture visitors of domain1.com
cond2: capture visitors who aren't already rewritten
rule: add 1/domain1/ to url to let script run normally.

Unfortunately this ain't working. Can anyboyd help?
AngTalunin
 
Posts: 1
Joined: Wed Oct 22, 2008 4:09 am

Postby richardk » Wed Oct 22, 2008 7:11 am

I have rules to rewrite this to something like:
page.php?id_domain=1 and page.php?id_domain=2

What mod_rewrite do you currently have? (Post it.)

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^(.*)$ /1/example.com/$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 19 guests

cron