|
Home > Archive > Apache Server configuration support > February 2006 > url-rewriting for multi-domain hosting with rewriterule?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
url-rewriting for multi-domain hosting with rewriterule?
|
|
|
| hi all,
i have a virtual hosting package with http://www.maindomain.com
now i've added a 'parked domain' (a different name) to the same hosting
package, but the problem is that both domains share the same web
document root.
i've created a nasty hack in that the index.php page in the web root
redirects users to the appropriate subdirectory for that domain based
upon which domain name they're access, but i really don't want to use
subdirectories for the web document roots.
is there a way to create url-rewriting so that, even though these
physical subdirectories will be there, that the subdirectory names will
be completely hidden in the URL ?
ie: so the urls will look like this:
http://www.maindomain.com/webroot1/ ==> http://www.maindomain.com/
http://www.parkeddomain.com/webroot2/ ==> http://www.parkeddomain.com/
thanks a lot for your help !
| |
|
| uhh...sorry - please don't click on the links in my post...these were
all intended by me to be sample links.
| |
| Davide Bianchi 2006-02-01, 7:53 am |
| On 2006-02-01, tom <tchurm@gmail.com> wrote:
> is there a way to create url-rewriting so that, even though these
> physical subdirectories will be there, that the subdirectory names will
> be completely hidden in the URL ?
Sure, is usually called "mass-defined virtual hosting", see the
documentation of Apache about it.
Davide
--
Why doesn't DOS ever say "EXCELLENT command or filename!"
| |
|
| uhh. there is the distinct possibility that i'm an idiot, but...
i google'd this for about an hour. tried about twenty possible
permutations out in my .htaccess file...and just couldn't get it to
work.
i have www.domain-a.com that i want to leave alone - it works fine.
then i bought www.domain-b.com and now it is parked to www.domain-a.com
so both domains are using the same document root.
presently, in the doc root, i have an php file doing redirects for
domain-b.com to another directory, let's call it
www.domain-b.com/workingdir
but what i really want is a rewriterule that makes it so that the user
doesn't see that all requests to domain-b.com are redirected to
/workingdir
the physical path of all scripts in domain-b.com/workingdir should
continue to work, but this directory should be invisible to the
visitor...thus /workingdir should become an invisible document root for
domain-b.com.
i'm pretty sure this is possible with the correct rewriterule, but for
someone ignorant of regex's, etc...it's not an easy task.
thanks !
| |
| Davide Bianchi 2006-02-01, 6:08 pm |
| On 2006-02-01, tom <tchurm@gmail.com> wrote:
> but what i really want is a rewriterule that makes it so that the user
> doesn't see that all requests to domain-b.com are redirected to
> /workingdir
Ah! I've missed that. Well, the only way is to have the DocumentRoot of
domain-b.com to /workingdir, unfortunately, you can't do that with
htaccess alone. A (bad) solution would be to have a frame page whose
internal frame point to /workingdir, but this would look really crappy.
Davide
--
I still miss Windows, but my aim is getting better.
| |
| Robert Ionescu 2006-02-01, 6:08 pm |
| tom wrote:
> is there a way to create url-rewriting so that, even though these
> physical subdirectories will be there, that the subdirectory names will
> be completely hidden in the URL ?
Yes.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?maindomain\.com
RewriteCond %{REQUEST_URI} !^/webroot1
Rewriterule ^(.*) /webroot1/$1 [L]
RewriteCond %{HTTP_HOST} ^(www\.)?parkeddomain\.com
RewriteCond %{REQUEST_URI} !^/webroot2
Rewriterule ^(.*) /webroot2/$1 [L]
An incomming request for maindomain.com/abc would point to
/webroot1/abc, a request for parkeddomain.com/abc would go to /webroot2/abc
> ie: so the urls will look like this:
> http://www.maindomain.com/webroot1/ ==> http://www.maindomain.com/
> http://www.parkeddomain.com/webroot2/ ==> http://www.parkeddomain.com/
No, the other way, maindomain.com/ --> maindomain.com/webroot1/
etc.
--
Robert
|
|
|
|
|