2 domains, domainA.com to domainB/folder/name/

Using a single web hosting account to host multiple sites

2 domains, domainA.com to domainB/folder/name/

Postby redpicasso » Thu Mar 08, 2007 11:24 am

Hi :)
i have a new question...
I have 2 domains:
www.redpicasso.com
and
xtreme-bg.net

for redpicasso.com i'm using:

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.redpicasso\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.redpicasso\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}C:/home/%2%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

RewriteCond %{HTTP_HOST} !^www\.redpicasso\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.redpicasso\.com$ [NC]
RewriteRule ^(.*)$ C:/home/%2/$1 [QSA,L]


now i want to use the secound domain without changeing of the URL, in other topic i found code similar to this:

Code: Select all
RewriteCond %{HTTP_HOST} ^(www\.)?xtreme-bg\.net$ [NC]
RewriteRule ^$ C:/home/bgxtreme/ [QSA,L]
RewriteCond %{HTTP_HOST} ^(www\.)?xtreme-bg\.net$ [NC]
RewriteRule ^(.*)?$ C:/home/bgxtreme/%{REQUEST_URI}  [QSA,L]


It works fine, but the url changes to www.redpicasso.com/home/bgxtreme/ and i don't want that ;)
I've tried with:

Code: Select all
RewriteCond %{HTTP_HOST} ^(www\.)?xtreme-bg\.net$ [NC]
RewriteRule ^$ C:/home/bgxtreme/ [QSA,L]
RewriteCond %{HTTP_HOST} ^(www\.)?xtreme-bg\.net$ [NC]
RewriteRule ^(.*)?$ C:/home/bgxtreme/%{REQUEST_URI}-d


This code doesn't change the URL but it return ERROR 404 "The webpage cannot be found"...
Can somebody help me? Please ;)
Thank You!
redpicasso
 
Posts: 6
Joined: Tue Feb 27, 2007 5:42 am

Postby richardk » Sat Mar 10, 2007 9:23 am

What are the document roots for each domain?

If it's you server and/or you have access to the httpd.conf file you should use <VirtualHost>s instead. Using Name-based Virtual Hosts.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby redpicasso » Sun Mar 11, 2007 8:38 am

mhm, the server is mine.
The document root for redpicasso.com is G:/apache/htdocs/ and with alias redpicasso.com/home/ points to C:/home/
The first code i use for subdomains and every subdomain at redpicasso.com to point into a directory at C:/home/ for example
alex.redpicasso.com
uses files from
redpicasso.com/home/alex
;)
now i want to point a user's domain to a specific folder again in C:/home/
the problem is that when i use:
Code: Select all
<VirtualHost 85.130.66.38>
ServerAdmin webmaster@xtreme-bg.net
DocumentRoot C:/home/bgxtreme
ServerName xtreme-bg.net
ErrorLog logs/xtreme-bg.net-error_log
TransferLog logs/xtreme-bg.net-access_log
</VirtualHost>

With mod_rewrite the two domains(redpicasso.com and xtreme-bg.com) go to same place insted of redpicasso.com to G:/apache.... and xtreme-bg.com to C:/home/...
redpicasso
 
Posts: 6
Joined: Tue Feb 27, 2007 5:42 am

Postby richardk » Sun Mar 11, 2007 3:25 pm

You need mod_vhost_alias enabled (uncomment it's LoadModule line in the httpd.conf file), then you shouldn't need any mod_rewrite at all.

In your httpd.conf file
Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
  ServerName redpicasso.com
  ServerAlias www.redpicasso.com
  DocumentRoot "C:/apache/htdocs"
  Alias /home "C:/home"
</VirtualHost>

<VirtualHost *:80>
  ServerName alex.redpicasso.com
  ServerAlias *.redpicasso.com
  DocumentRoot "C:/apache/htdocs"
  VirtualDocumentRoot "C:/home/%-3"
</VirtualHost>

<VirtualHost *:80>
  ServerName xtreme-bg.net
  ServerAlias *.xtreme-bg.net
  DocumentRoot "C:/home/bgxtreme"

  ServerAdmin webmaster@xtreme-bg.net
  ErrorLog logs/xtreme-bg.net-error_log
  TransferLog logs/xtreme-bg.net-access_lo
</VirtualHost>
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 23 guests

cron