Please Help!

Using a single web hosting account to host multiple sites

Please Help!

Postby Prosis » Sun Sep 10, 2006 4:44 pm

Hello

To begin, I have no idea how these characters work: ^/~ etc..

Second, I've been searching the net all day and have not found the answer (even in the Apache documentation). I know I suck :P

Third, I have particular questions and no one in other forums seem able to do something else than point me to the Apache documentation which I do not understand. I am a complete newbie concerning the matter. So I would like to apologize in advance for my ignorance :P

Ok, I have two domains. Say the first is www.first.ca and the second is www.second.com. Currently, www.first.ca points, with nameservers, to the root of my host. I have bought www.second.com subsequently.

Basically what I want to do is use mod_rewrite so that www.second.com is redirected to a subfolder of my host so I can use it for something completely different than the first one (the first is for my blog the second is for my company).

Now while my company website is in the works, I have confirgured my second domain directly to the subfolder in question but this is only for a "Coming Soon" because it cannot be used as a domain with subfolders and whatnot. Here are my questions:

1-What do I write in my .htaccess (s)
2-Where do I put them?
3-How should I configure my www.second.com?

Thank you and bless the one who will give me a clear precise answer :P
Prosis
 
Posts: 7
Joined: Sun Sep 10, 2006 4:31 pm

Postby Prosis » Mon Sep 11, 2006 7:31 am

I would like to add that I've tried several solutions that look likke this:

RewriteEngine on
RewriteCond %{HTTP_HOST} domaina.com
RewriteCond %{REQUEST_URI} !^/a/
RewriteRule ^(.*) a/$1 [L]

but none of them work. I have Apache 2.something on my host
Prosis
 
Posts: 7
Joined: Sun Sep 10, 2006 4:31 pm

Postby richardk » Mon Sep 11, 2006 11:07 am

To begin, I have no idea how these characters work: ^/~ etc..

Then you should learn about regular expressions: http://www.regular-expressions.info/tutorial.html

Now while my company website is in the works, I have confirgured my second domain directly to the subfolder in question but this is only for a "Coming Soon" because it cannot be used as a domain with subfolders and whatnot.

If second.com is set to a subdirectory of first.ca why can't you make subdirectories and whatnot inside that directory?

If you were going to use mod_rewrite to setup subdomains you'd need need second.com pointed to the same dircetory as first.ca, then you could use this:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?second\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/SUBDIR%{REQUEST_URI}/ -d
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

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

Postby Prosis » Mon Sep 11, 2006 11:51 am

richardk wrote:If second.com is set to a subdirectory of first.ca why can't you make subdirectories and whatnot inside that directory?


I didn't express myself correctly, I apologize. I meant I set up my domain as a redirection only. That's why I can't use it as a regular domain.

I had some help from my registrar as well and I will be able to try your solution in 12-24 hours (I set the DNS and added my domain to my host).

Thanks!
Prosis
 
Posts: 7
Joined: Sun Sep 10, 2006 4:31 pm

Postby Prosis » Mon Sep 11, 2006 5:39 pm

Great it works, not with what you wrote though, I got a 500 Internal Error...

But with

RewriteEngine on
RewriteCond %{HTTP_HOST} domaina.com
RewriteCond %{REQUEST_URI} !^/a/
RewriteRule ^(.*) a/$1 [L]

It did pretty much what I want except for one detail. If I want to go to www.second.com/test/ the url in the address bar becomes www.second.com/second/test/

How can I go around this?
Prosis
 
Posts: 7
Joined: Sun Sep 10, 2006 4:31 pm

Postby richardk » Tue Sep 12, 2006 7:22 am

There's nothing wrong with the code i gave you, try this:
Code: Select all
RewriteEngine On

# mod_dir fix
RewriteCond %{HTTP_HOST} ^(www\.)?second\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/second%{REQUEST_URI}/ -d
RewriteRule !/$ %{REQUEST_URI}/ [R=301,L]

# second.com --> /second/
RewriteCond %{HTTP_HOST} ^(www\.)?second\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/second(/.*)?$
RewriteRule ^(.*)$ /second%{REQUEST_URI} [QSA,L]


Then this:
Code: Select all
RewriteEngine On

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

Postby Prosis » Tue Sep 12, 2006 7:29 am

And I put all of this in one single .htacces?
Prosis
 
Posts: 7
Joined: Sun Sep 10, 2006 4:31 pm

Postby richardk » Tue Sep 12, 2006 8:05 am

No, you try the first one, then the other. They need to go in a .htaccess file in your main document root.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Prosis » Tue Sep 12, 2006 1:50 pm

ok the first one sends me to: http://www.second.com///////////////////// until the browser tells me it will never arrive

And the second still sends me to www.second.com/second/test/ when I type in www.second.com/test/

I would like to hide the /second/ from users...
Prosis
 
Posts: 7
Joined: Sun Sep 10, 2006 4:31 pm

Postby richardk » Tue Sep 12, 2006 2:19 pm

In the first, replace !/$ with [^/]$, then clear your browser's cache and try it.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Next

Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 97 guests

cron