Making two domain names one

Discuss practical ways rearrange URLs using mod_rewrite.

Making two domain names one

Postby Nervosa » Fri Nov 07, 2008 10:38 am

I currently have a set up so a URL and a sub domain of another url link to the same content.

example:
domainA.com and sub1.domainB.com link to the same content.
I had my host set this up not sure what was done.

What I would like to do is rewrite sub1.domainB.com to domainA.com, is this possable?
Nervosa
 
Posts: 14
Joined: Mon Aug 18, 2008 3:04 pm

Postby richardk » Fri Nov 07, 2008 11:49 am

I don't understand what you want.

When you go to sub1.domainB.com what should happen? What site/files should you see?
When you go to domainA.com what should happen? What site/files should you see?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Nervosa » Fri Nov 07, 2008 1:03 pm

If you go to either domainA.com or sub1.domainB.com, you will see the same content.
So domainA.com/file.php and sub1.domainB.com/file.php is the same thing.

I no longer want to use to different urls for the same thing.
I would like it so when someone clicks a link or types in sub1.domainB.com, it turns into domainA.com.
Nervosa
 
Posts: 14
Joined: Mon Aug 18, 2008 3:04 pm

Postby richardk » Sun Nov 09, 2008 11:47 am

Right, try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Nervosa » Sun Nov 09, 2008 1:28 pm

So it I want to make 123.exampleB.com into exampleA.com, is this how it should look?

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^123\.exampleB\.com$ [NC]
RewriteRule ^(.*)$ http://www.exampleA.com/$1 [R=301,L]
Nervosa
 
Posts: 14
Joined: Mon Aug 18, 2008 3:04 pm

Postby richardk » Mon Nov 10, 2008 2:29 pm

No, you want
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.exampleA\.com$ [NC]
RewriteRule ^(.*)$ http://www.exampleA.com/$1 [R=301,L]

It means, if it's not www.exampleA.com, redirect to www.exampleA.com.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 23 guests

cron