Forum Moderators: phranque

Message Too Old, No Replies

Two Domains Pointed To Share Server

How to point multiple domains to a share server using .htaccess

         

TeamSDA

7:47 pm on Nov 8, 2011 (gmt 0)

10+ Year Member



Hi All,

I've trying to point two domains to a single shared server using .htaccess. Below I have some code I found from another post but I can get it to work correctly.

In the directory I have my .htaccess file with the code that is below. As well as two folders called "siteone" and "sitetwo" with a simple index.html inside both. Everything works if you go to exactly [siteone.com....] If you type siteone.com in the url it pulls up [siteone.com...]

What is going on and how can I fix this? Thank you for your help!





RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^(www.)?siteone.com$
RewriteCond %{REQUEST_URI} !^/siteone/
RewriteRule ^(.*)$ /siteone/$1


RewriteCond %{HTTP_HOST} ^(www.)?sitetwo.com$
RewriteCond %{REQUEST_URI} !^/sitetwo/
RewriteRule ^(.*)$ /sitetwo/$1



RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html(\?[^\ ])?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http://www.siteone.com/$1 [R=301,L]


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



RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html(\?[^\ ])?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http://www.sitetwo.com/$1 [R=301,L]


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





Christian

wilderness

8:16 pm on Nov 8, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



do a search in the archives for "domain2" and "domain1".
This comes up fairly often.

TeamSDA

7:26 am on Nov 9, 2011 (gmt 0)

10+ Year Member



Hi Wilderness,

I've done some searching but all the examples I find are giving the same issue as what I have detailed above.

Could you point me in the right direction? Thank you for you help.


Christian

lucy24

8:26 am on Nov 9, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm missing something. Possibly that makes two of us.

In the two rules

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html(\?[^\ ])?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http://www.siteone.com/$1 [R=301,L]


and

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html(\?[^\ ])?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http://www.sitetwo.com/$1 [R=301,L]


how does mod_rewrite know that the first of two identical Rules pertains only to siteone and the second pertains only to sitetwo?

TeamSDA

3:53 pm on Nov 9, 2011 (gmt 0)

10+ Year Member



My experience with .htaccess is very limited. The mod_rewrite rule you have pointed out is something we used for a single website and I thought it might work the same for multiples domains.

How would I separate them?

wilderness

4:11 pm on Nov 9, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



"domain2" +2011 [google.com]

The SEARCH link is located on the second line of the Webmaster World header near the very top of this page, and every other page at Webmaster World.

lucy24

11:18 pm on Nov 9, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



One more question. What happens if you remove the htaccess file entirely? Do you get taken to the appropriate domain? If not, it may be a DNS issue that needs sorting-out. If each domain actually exists-- that is, it's not a parked name being redirected-- and each one has its own physical directory, then it shouldn't be necessary for htaccess to say anything at all about the domain names.