Two domains on same ip host

Using a single web hosting account to host multiple sites

Two domains on same ip host

Postby alcohol » Wed Oct 10, 2007 11:58 am

Hello,
Here is my problem, hope you can solve it:

I have 2 domains: domain1.com and domain2.com and they both have the ip 127.0.0.1 but diferent dns'es. The original hosting account is only for domain1.com and i set the same ip for domain2 too.

Now, since they have different content types i want domain2.com to have the docroot on domain1.com/folderd4domain2/.
I tried the example from apache doc but it doesnt work right.

#RewriteEngine on
#RewriteCond %{HTTP_HOST} ^(.*)domain2\.com$
#RewriteRule ^/$ http://www.domain1.com/folder4domain2/ [L]
#Iniatilly it was [R,L] but i removed the R, because i don't know if search engines see it like a redirect.

It does work somehow but it ads an extra slashlike this:
http://www.domain2.com//myfile.html

Hope you can help me with some advice,
Thank you.
alcohol
 
Posts: 2
Joined: Wed Oct 10, 2007 11:41 am

Postby richardk » Wed Oct 10, 2007 2:14 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# Fix missing trailing slashes.
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/folderd4domain2%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

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

Postby alcohol » Thu Oct 11, 2007 1:10 am

It act the same as before. I'm using joomla and when I activate SEF urls it ads an extra slash like this http://www.domain2.com//news/7/ and the urls become useless.

So I'll have to guess is because the software since both your htaccess config and mine act the same.

Since I'm not a big modrewrite expert I'll go on your hand and use your htacces config.
I hope I'll find a solution for this exxtra slash problem because it became a nightmare.

Thanks for your time.
alcohol
 
Posts: 2
Joined: Wed Oct 10, 2007 11:41 am

Postby richardk » Fri Oct 12, 2007 11:08 am

Is it in the HTML source of the page? Is there anything wrong with the link in the source of the page?

You could try adding
Code: Select all
RewriteCond %{THE_REQUEST} \ ([^\ \?]*)/(/[^\ \?]*)(\?.*)?\  [NC]
RewriteRule .* %1%2 [R=301,L]

after
Code: Select all
RewriteEngine On

as a temporary fix until you find the real issue.
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 22 guests

cron